$ _FILE上传大文件提供了错误1,即使upload_max_size比文件大小
问题描述:
我有一个简单的上传表单更大:
enctype="multipart/form-data"/>
和
input type="hidden" name="MAX_FILE_SIZE" value="5900000" />
并进行如下设置,是在php.ini中应用(通过phpini()进行检查):
upload_max_filesize = 7MB
memory_limit = 64M
post_max_size = 8MB
我尝试上传一个小文件 - 500k,它通过GH
我尝试上传的文件是5MB(超过两upload_max_filesize
和post_max_size
设置更小),它失败,错误代码1:这说的是:
UPLOAD_ERR_INI_SIZE 值:1;上传的文件超出了php.ini中的upload_max_filesize指令。
任何人都有线索是怎么回事?
答
我认为这是因为一个错字。取而代之的
upload_max_filesize = 7MB
应改为
upload_max_filesize = 7M
使用phpinfo()
再次检查实际上得到应用什么样的价值。
答
您还可以设置“的php.ini”
答
upload_max_filesize = 7M
here the value is in 7M or 10M but not MB.
use `phpinfo()` again to check what value actually gets applied.
运行这个程序也一度可以更容易理解的问题是什么post_max_size
如果文件大小的扩展意味着简单地把它打印出来把为超过php.ini中的upload_max_filesize指令
<?php
$error_types = array(
1=>'The uploaded file exceeds the upload_max_filesize directive in php.ini.',
'The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form.',
'The uploaded file was only partially uploaded.',
'No file was uploaded.',
6=>'Missing a temporary folder.',
'Failed to write file to disk.',
'A PHP extension stopped the file upload.'
);
// Outside a loop...
if($_FILES['userfile']['error']==0) { // here userfile is the name i.e(<input type="file" name="*userfile*" size="30" id="userfile">
echo"no error ";
} else {
$error_message = $error_types[$_FILES['userfile']['error']];
echo $error_message;
}
by this we can easily identifies the poblem or we can use switch case also to print
答
这是一个很大的错误,我已经做了:
如果你想上传真正的大文件,你必须设置KeepAliveTimeout
高于5
秒的默认值。
例如:
KeepAliveTimeout 300
你可以找到/etc/apache2/apache2.conf
答
转到这个属性W¯¯HM->Service Configuration->PHP Configuration Editor
和更新的upload_max_filesize
值。
你是对的,解决了这个问题。我没有意识到的技巧是phpinfo()确实显示了7MB的值,但它并不认为它适合。现在都很好,luv ya – mgpepe 2010-11-23 11:43:35
+1好点:) – karim79 2010-11-23 11:44:24