admin管理员组

文章数量:1389826

I'm having issues with a file uploading utility in my PHP application. When sending large files (9MB+) over the form, I get a very odd behaviour: the POST data I've included in the form dissapears, including the file information.

I've already increased all PHP limits I could (time limit, max input time, post max size, memory limit and upload max filesize) and I still can't get the proper behaviour. I've tried replacing the regular HTTP forms with a Flash-based solution (SWFUpload, www.swfupload), still the same behaviour.

I've tried multiple files of similar sizes and its definitely not a particular file issue. I've debugged the POST vars sent using Firebug, and the correct variables are still there in the header, together with the file.

What could be going on here?

I'm having issues with a file uploading utility in my PHP application. When sending large files (9MB+) over the form, I get a very odd behaviour: the POST data I've included in the form dissapears, including the file information.

I've already increased all PHP limits I could (time limit, max input time, post max size, memory limit and upload max filesize) and I still can't get the proper behaviour. I've tried replacing the regular HTTP forms with a Flash-based solution (SWFUpload, www.swfupload), still the same behaviour.

I've tried multiple files of similar sizes and its definitely not a particular file issue. I've debugged the POST vars sent using Firebug, and the correct variables are still there in the header, together with the file.

What could be going on here?

Share Improve this question asked May 21, 2010 at 19:18 DfKimeraDfKimera 2,1462 gold badges21 silver badges40 bronze badges 3
  • 1 How about looking in the server logs. Try to spot any errors / warnings. – nc3b Commented May 21, 2010 at 19:22
  • I'm having the same issue. Did you solve your problem? – Pherrymason Commented Dec 29, 2010 at 10:56
  • server logs should give you an idea. Also look at the php error log, if available. – Salman Arshad Commented Dec 29, 2010 at 11:15
Add a ment  | 

4 Answers 4

Reset to default 2

Web servers can also be configured to limit request sizes. If you're using Apache, check out the LimitRequestBody directive.

Ok, I think I have the solution. You must check for both post_max_size directive and $_SERVER['CONTENT_LENGTH'], so if $_SERVER['CONTENT_LENGTH'] surpasses post_max_size means that they are trying to upload too many data.

$POST_MAX_SIZE = ini_get('post_max_size');
$mul = substr($POST_MAX_SIZE, -1);
$mul = ($mul == 'M' ? 1048576 : ($mul == 'K' ? 1024 : ($mul == 'G' ? 1073741824 : 1)));
if( $_SERVER['CONTENT_LENGTH'] > $mul*(int)$POST_MAX_SIZE && $POST_MAX_SIZE )
{
    $error = true;
}

Solution taken from here: http://www.php/manual/en/features.file-upload.php#73762

try uploading small files of 1 - 2 MB .if you still not able to post the code .

hope you have added enctype='/multipart/form-data' in form definition .

What server are you running on? I think some servers OS have a limit set of how large files they allow. This value can be changed.

本文标签: phpPOST data disapearing on large file uploadStack Overflow