PHP $_FILES中error返回值详解_PHP教程
UPLOAD_ERR_OK: 0 //正常,上传成功
UPLOAD_ERR_INI_SIZE: 1 //上传文件大小超过服务器允许上传的最大值,php.ini中设置upload_max_filesize选项限制的值
UPLOAD_ERR_FORM_SIZE: 2 //上传文件大小超过HTML表单中隐藏域MAX_FILE_SIZE选项指定的值
UPLOAD_ERR_NO_TMP_DIR: 6 //没有找不到临时文件夹
UPLOAD_ERR_CANT_WRITE: 7 //文件写入失败
UPLOAD_ERR_EXTENSION: 8 //php文件上传扩展没有打开
UPLOAD_ERR_PARTIAL: 3 //文件只有部分被上传
switch($_FILES[$field]['error']) {
case 1:
// 文件大小超出了服务器的空间大小
$this->setError("The file is too large (server).");
break;
case 2:
// 要上传的文件大小超出浏览器限制
$this->setError("The file is too large (form).");
break;
case 3:
// 文件仅部分被上传
$this->setError("The file was only partially uploaded.");
break;
case 4:
// 没有找到要上传的文件
$this->setError("No file was uploaded.");
break;
case 5:
// 服务器临时文件夹丢失
$this->setError("The servers temporary folder is missing.");
break;
case 6:
// 文件写入到临时文件夹出错
$this->setError("Failed to write to the temporary folder.");
break;
}
推荐阅读
-
PHP $_FILES中error返回值详解_PHP教程
-
php中spl_autoload详解,spl_autoload详解_PHP教程
-
php中mysql连接方式PDO使用详解_PHP教程
-
探讨多键值cookie(php中cookie存取数组)的详解_PHP教程
-
PHP入门教程之自定义函数用法详解(创建,调用,变量,参数,返回值等)
-
PHP入门教程之自定义函数用法详解(创建,调用,变量,参数,返回值等)
-
PHP5中SESSION路径配置详解_PHP教程
-
PHP中set error handler函数用法小结,sethandler_PHP教程
-
php中防xss攻击和sql注入详解_PHP教程
-
php中拷贝构造函数、赋值运算符重载详解_PHP教程