Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

When uploading multipart/form-data forms via a http post request to my apache web server, very big files (i.e. 30MB) are silently discarded. On the server side all looks as if the attached file was received with 0 bytes size. On the client side all looks like it had been uploaded succesfully (it takes the expected long time to upload and the browser gives no error message).

On the server, nothing is logged into the error log. An entry is logged into the access log as if everything was ok (a post request and a 200 ok response). These uploads are being posted to a php script. In the php script, If I print_r $_FILES, I see the following information for the relevant file:

[file5] => Array
            [name] => MOV023.3gp
            [type] => video/3gpp
            [tmp_name] => /tmp/phpgOdvYQ
            [error] => 0
            [size] => 0

Note both [error] => 0 (which should mean no error) and [size] => 0 (as if the file was empty).

My php script runs fine and receives all the rest of the data except these files. move_uploaded_file succeeds on these files and actually copies them as 0byte files.

I've already changed the php directives max_upload_size to 50M and post_max_size to 200M, so neither the single file nor the request exceed any size limit.

max_execution_time is not relevant, because the time to transfer the data does not count; and I've increased max_input_time to 1000 seconds, though this shouldn't be necessary since this is the time taken to parse the input data, not the time taken to upload it.

Is there any apache configuration, prior to php, that could be causing these files to be discarded even prior to php execution? Some limit in size or in upload time?

I've read about a default 300 seconds timeout limit, but this should apply to the time the connection is idle, not the time it takes while actually transferring data, right?

Needless to say, uploads with all exactly identical conditions (including file format, client and everything) except smaller file size, work seamlessly, so the issue is clearly related to the file or request size, or to the time it takes to send it.

share|improve this question
Did you restart Apache when you modified the settings in php.ini? –  Ben Pilbrow Nov 28 '11 at 19:11
Check your memory limits, as they also need to support the large files (including the PHP scripts that runs) –  pauska Nov 28 '11 at 19:12
Can we get the output of the php.ini? –  Rilindo Nov 28 '11 at 19:21
Ben, I changed the settings in .htaccess, not php.ini, so I don't need to restart apache. I'm 100% sure the new settings are in effect, since the previous limit in file size was 2MB and files bigger than 2M were rejected and now they aren't. –  matteo Nov 28 '11 at 21:58
pauska, do you mean some apache memory limit, or php's memory limit? How much exactly should I increase it? I don't believe it needs to load the whole file into memory, or does it? (that would be a ridiculously bad implementation if it did!!). My current memory limit is 128M, that should be more than enough for a 30M file even if it had to load it into memory, isn't it? –  matteo Nov 28 '11 at 22:02

1 Answer 1

You must increase max excution time of PHP. Because php file must keep alive during post action. Also please check your server capacity. Because of full hard disk, your tem file may not be add to tmp directory. You must have at least 31M free space to upload 30M file (If your server is shared host). In the case of VPN or dedicated server you need more than mentioned free space. Because you need moving file from tmp dir to your required directory.

As your feedback, any error found on uploading proccess and it may be resualt of lack of free space or php excution time.

Please note: Some servers prevent php scripts to change some .ini file specifications. Please chack it whether your settings did activated or not.

share|improve this answer
php max_execution_time CLEARLY ISN'T the issue: 1. if it was, the script would be interrupted and would generate a 500 server error, which is not the case as I clearly stated in the question –  matteo Dec 7 '11 at 16:12
2. max_execution_time only concerns the time spent running the script which starts AFTER the input has been received. From php.net: "The set_time_limit() function and the configuration directive max_execution_time only affect the execution time of the script itself. Any time spent on activity that happens outside the execution of the script such as system calls using system(), stream operations, database queries, etc. is not included when determining the maximum time that the script has been running. –  matteo Dec 7 '11 at 16:13
regarding "any error found on uploading process" as I already said no error is logged on the server side and no error is shown on the client side –  matteo Dec 7 '11 at 16:15
I wish I could give a -1 –  matteo Dec 7 '11 at 16:15
Ah, then I TRIED increasing max_execution_time but it didn't help, as expected. I'll check the disk space thing but if I have enough space for uploading dozens of 5MB files I guess I have enough for one 30MB file. By the way it's a dedicated server –  matteo Dec 7 '11 at 16:18

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.