0
我有这样的代码PHP MIME类型,限制上传文件
if(isset($_FILES['uploadfile']))
{
$maxsize = 10485760; //10MBx1024
$acceptable = array(
'image/jpeg',
'image/jpg',
'image/gif',
'image/png',
'application/pdf',
'text/plain',
'application/vnd.ms-excel',
'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
'application/vnd.ms-word',
'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
'application/zip',
'application/x-zip-compressed',
'application/x-compressed',
);
,这是以下几个部分:
if((!in_array($_FILES['uploadfile']['type'], $acceptable)) && (!empty($_FILES["uploadfile"]["type"])))
{
$msg= "<b><img src=redwarn.png'><font color='red'> This file is not accepted.</b></font>";
goto cancel;
}
上面的代码可以限制用户上传,但我试图延长上传一个IMAGE文件,出现一个文件未被接受的错误,但我在数组中添加了'image/jpeg'
,我的代码中是否有任何错误?
感谢
你问是否有与此代码的任何错误?你有没有看到任何问题?或者这只是一个代码审查请求? – Lix
如果这是一个代码审查请求,那么它不适合[so]。也许[Codereview.SE](http://codereview.stackexchange.com/)是一个更好的地方发布这个。 – Lix
你想问什么? –