Project

General

Profile

Problem uploading files > 1MB with lighttpd, php and fastcgi

Added by jmac over 16 years ago

Hi,
I'm new to lighttpd, php and fastcgi so if this has already been answered or the problem is with php...

Anwyay, I am using POST to upload files to a server. Uploading any file under 1MB works ok but files > 1MB always fail. They arrive as ~1MB chunks at the server but if theres more than one file chunk the server just deletes them and the operation fails. Ive spent about a day searching the web for solutions now and am a bit stumped!

Example files generated by a 5,857,280 byte file:

-rw-------    1 root     root       594806 Dec  1 17:59 lighttpd-upload-ziIeuD
-rw-------    1 root     root      1048576 Dec  1 17:59 lighttpd-upload-VoLsu0
-rw-------    1 root     root      1056768 Dec  1 17:59 lighttpd-upload-UjbOgs
-rw-------    1 root     root      1052672 Dec  1 17:59 lighttpd-upload-NuJp5E
-rw-------    1 root     root      1052672 Dec  1 17:59 lighttpd-upload-EOn4R6
-rw-------    1 root     root      1052121 Dec  1 17:59 lighttpd-upload-05aBEe

In lighttpd.conf:

server.network-backend = "writev" 

In php.ini:
file_uploads = On
pos_max_size = 14M
upload_max_filesize = 7M
memory_limit = -1

The upload page and php has been borrowed from http://www.tizag.com/phpT/fileupload.php

On the upload page:

<form enctype="multipart/form-data" action="uploader.php" method="POST">
        <br />
        <input type="hidden" name="MAX_FILE_SIZE" value="10000000" />

        Choose a file to upload: <input name="uploadedfile" type="file" /><br />
        <input type="submit" value="Upload File" />
</form>

uploader.php:

<?php
   $target_path = "/var/uploads/";
   $target_path = $target_path . basename( $_FILES['uploadedfile']['name'])

   echo '<pre>';
   if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)
        echo     "The file ".  basename( $_FILES['uploadedfile']['name']).
                " has been uploaded\r\n";
   } else {
      echo "There was an error uploading the file, please try again!\r
      print_r($_FILES);
   }
    print "</pre>";
?>

Im using lighttpd v1.4.20, php 5.2.3 cross-compiled onto an Axis Etrax 100LX running Linux 2.4.31.

Any help would be appreciated, thanks!


Replies (1)

RE: Problem uploading files > 1MB with lighttpd, php and fastcgi - Added by jmac over 16 years ago

Ok so I'm the numpty!

In php.ini
post_max_size = 1M

Changed to something bigger and it all starts working.

    (1-1/1)