如何在PHP的$ _FILE数组中查看错误消息 [英] How to see the error message in $_FILE array in PHP
本文介绍了如何在PHP的$ _FILE数组中查看错误消息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用多个文件上传功能,当我将文件数组打印为时出现错误:
I am working on multiple file upload functionality where I am getting error when I print the file array as:
print_r($_FILE);
得到错误为:
Array
(
[name] => _agiewniki_Forrest_in_Autumn.jpg
[type] =>
[tmp_name] =>
[error] => 1
[size] => 0
)
我没有看到错误说明,仅此错误
I don't see the error description, the error only this
[error] => 1
推荐答案
您可以使用此数组显示文件上传错误消息:
You can use this array to display file-upload error messages:
$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']];
这篇关于如何在PHP的$ _FILE数组中查看错误消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文