[英]How to see the error message in $_FILE array in PHP
我正在使用多种文件上传功能,在将文件数组打印为时出现错误:
print_r($_FILE);
获取错误为:
Array
(
[name] => _agiewniki_Forrest_in_Autumn.jpg
[type] =>
[tmp_name] =>
[error] => 1
[size] => 0
)
我没有看到错误说明,仅此错误
[error] => 1
您可以使用此数组显示文件上传错误消息 :
$error_messages = array(
UPLOAD_ERR_OK => 'There is no error, the file uploaded with success',
UPLOAD_ERR_INI_SIZE => 'The uploaded file exceeds the upload_max_filesize directive in php.ini',
UPLOAD_ERR_FORM_SIZE => 'The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form',
UPLOAD_ERR_PARTIAL => 'The uploaded file was only partially uploaded',
UPLOAD_ERR_NO_FILE => 'No file was uploaded',
UPLOAD_ERR_NO_TMP_DIR => 'Missing a temporary folder',
UPLOAD_ERR_CANT_WRITE => 'Failed to write file to disk',
UPLOAD_ERR_EXTENSION => 'A PHP extension stopped the file upload',
);
// prints "The uploaded file exceeds the upload_max_filesize directive in php.ini"
echo $error_messages[$_FILES['error']];
http://www.php.net/manual/zh/features.file-upload.errors.php
UPLOAD_ERR_INI_SIZE值:1; 上传的文件超出了php.ini中的upload_max_filesize指令。
希望对大家有帮助
在这里您可以通过错误代码找到说明
您的情况是: The uploaded file exceeds the upload_max_filesize directive in php.ini.
基于$_FILES['userfile']['error']
值,您可以在ref文档中打印相应的错误消息。
将所有错误消息添加到具有相应错误键值的某个数组中。 根据上传过程中从$_FILE
接收到的错误键值,并显示相应的错误消息[在下面添加链接]。
错误消息解释:
错误值:1; 上传的文件超出了php.ini中的upload_max_filesize指令。
有关更多信息和参考,请访问: http : //www.php.net/manual/zh/features.file-upload.errors.php
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.