Http File upload - Files over 25mb fail - PHP uploading script
I've been banging my head against this for 20+ hours now I would really appreciate some help!
I have simplified the problem here so the code is very simple. Basically this upload script works perfectly until I try to upload a file bigger than 25MB then it fails. PHP gives no errors.
index.htm
<form enctype="multipart/form-data" action="upload.php" method="POST">
Choose a file to upload: <input name="uploadedfile" type="file" /><br />
<input type="submit" value="Upload File" />
</form>
upload.php
<?php
$target_path = "uploaded/";
$target_path = $target_path.basename( $_FILES['uploadedfile']['name']);
/***/highlight_string(print_r($_FILES, true)); //check array
if (move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) {
echo "The file ". basename($_FILES['uploadedfile']['name'])." has been uploaded";
} else {
echo "There was an error uploading the file, please try again!";
}
?>
php.ini
[PHP]
post_max_size = 32M
upload_max_filesize = 32M
My host informed me that the upload limit on the server is 32MB. Ran phpinfo() & the variables in the ini are being changed. It is not a timeout issue (ran a 16mb upload when downloading a file - it took several minutes longer than the 25MB upload but still worked).
I have been spittin out the $_Files array as a string for error checking, heres what I get when it fails:
Array
(
[uploadedfile] => Array
(
[name] => 30.tif
[type] =>
[tmp_name] =>
[error] => 7
[size] => 0
)
)
There was an error uploading the file, please try again!
Any ideas? Tried it on different servers with the 开发者_JAVA技巧same problem.
According to this, it failed to write files to disk. Can you check quota/disk space/etc.?
memory_limit might also restrict the size of uploadable files.
Your error don't is for the size, the error code 7 is because the file "can't be save in the disk."
to more errors read: Upload code errors
Try change the directive "upload_tmp_dir" in php.ini file and check if is allow the upload of file: 'file_uploads = On'.
Thanks everybody, I'm sure now that it is a host problem, not a problem on my end - even though I've tried it on several hosts - I think it's pretty common for http post to be limited to around 25MB.
I have now set my uploader to take a maximum file size of 20MB, that should make it pretty safe on most hosts.
精彩评论