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.org), still the same behaviour.
I've tried multiple files of similar sizes an开发者_如何学JAVAd 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?
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.net/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.
精彩评论