问题解决
$filetype=$_FILES['userfile']['type'];
echo"$filetype"; 就可看到上传文件的mime类型.
ZIP的MIME类型用application/x-zip-compressed
RAR的MIME类型用application/octet-stream 你的代码可修改为:
switch ($_FILES['userfile']['type']) {
case "application/x-zip-compressed":
break;
case "application/octet-stream":
break;
case "text/plain":
break;
default:
print "您上传的文件类型不对";
exit(0);
break;
}
$filetype=$_FILES['userfile']['type'];
echo"$filetype"; 就可看到上传文件的mime类型.
ZIP的MIME类型用application/x-zip-compressed
RAR的MIME类型用application/octet-stream 你的代码可修改为:
switch ($_FILES['userfile']['type']) {
case "application/x-zip-compressed":
break;
case "application/octet-stream":
break;
case "text/plain":
break;
default:
print "您上传的文件类型不对";
exit(0);
break;
}
早些的文件不区分ZIP和RAR的
不过你可以自己计算文件头 或者手动写到那个文件里
RAR的头是“\x52\x61\x72\x21”
ZIP的是“\x50\x4b\x03\x05”