php文件上传错误值演示示例

发布时间:2020-01-13编辑:脚本学堂
分享一个php文件上传错误代码判断的小例子,了解下php文件上传时对错误消息的处理方法,需要的朋友参考下。

例子,php文件上传错误处理。
 

复制代码 代码示例:
switch ($_FILES['Filedata']['error']) { 
    case 0: 
        $msg = "No Error";  
        break
    case 1: 
        $msg = "The file is bigger than this PHP installation allows"; 
        break; 
    case 2: 
        $msg = "The file is bigger than this form allows"; 
        break; 
    case 3: 
        $msg = "Only part of the file was uploaded"; 
        break; 
    case 4: 
        $msg = "No file was uploaded"; 
        break; 
    case 6: 
        $msg = "Missing a temporary folder"; 
        break; 
    case 7: 
        $msg = "Failed to write file to disk"; 
        break; 
    case 8: 
        $msg = "File upload stopped by extension"; 
        break; 
    default: 
        $msg = "unknown error ".$_FILES['Filedata']['error']; 
        break; 

echo ($msg) ? "Error: ".$_FILES['Filedata']['error']." Error Info: ".$msg : "1"; 
//1  This is required for onComplete to fire on Mac OSX