PHP – $_FILES中error返回值
PHP处理表单上传文件使用$_FILES[fieldName][‘error’]来标识正确与否与错误信息。详情如下。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
switch($_FILES[$field]['error']) { case 0: // 正常 break; 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; } |