[英]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! 我已经为此奋斗了20多个小时,非常感谢您的帮助!
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.
基本上,此上传脚本可以完美运行,直到我尝试上传大于25MB的文件然后失败为止。 PHP gives no errors.
PHP没有给出错误。
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 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.ini
[PHP]
post_max_size = 32M
upload_max_filesize = 32M
My host informed me that the upload limit on the server is 32MB. 我的房东告诉我,服务器上的上传限制为32MB。 Ran phpinfo() & the variables in the ini are being changed.
冉phpinfo()和ini中的变量被更改。 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).
这不是超时问题(下载文件时上传了16mb的文件-比25MB的上传花费了几分钟的时间,但仍然可以使用)。
I have been spittin out the $_Files array as a string for error checking, heres what I get when it fails: 我已经将$ _Files数组作为一个字符串进行错误检查,这是失败时得到的信息:
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 same problem.
在具有相同问题的不同服务器上进行了尝试。
memory_limit也可能会限制可上传文件的大小。
Your error don't is for the size, the error code 7 is because the file "can't be save in the disk." 您的错误不是关于大小,错误代码7是因为文件“无法保存在磁盘中”。
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'. 尝试在php.ini文件中更改指令“ upload_tmp_dir”,并检查是否允许上传文件:“ 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. 谢谢大家,我现在确定这是一个主机问题,不是我要解决的问题-即使我已经在多个主机上进行了尝试-我认为http帖子限制在25MB左右是很普遍的。
I have now set my uploader to take a maximum file size of 20MB, that should make it pretty safe on most hosts. 现在,我已将上传器设置为最大文件大小为20MB,这应该可以使它在大多数主机上非常安全。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.