相关疑难解决方法(0)

将文件上载选择限制为特定类型

无论如何要通过<input type="file" />元素限制文件类型的选择?

例如,如果我只想上传图像类型,我会将可能的选择限制为(image/jpg,image/gif,image/png),选择对话框会使其他mime类型的文件变灰.

ps我知道我可以通过扫描.type属性在File API之后执行此操作.我真的试图限制这一点..我也知道我可以通过闪存做到这一点,但我不想为此使用闪存.

html5 file-upload fileapi

48
推荐指数
2
解决办法
4万
查看次数

php文件上传,如何限制文件上传类型

我有以下代码来检查(上传的简历和推荐信是否符合所需类型(pdf或doc或docx)和大小(小于400 kb)

//check file extension and size
         $resume= ($_FILES['resume']['name']); 
         $reference= ($_FILES['reference']['name']); 
         $ext = strrchr($resume, ".");
         $ext1 = strrchr($reference, ".");
        if (!(($_FILES["resume"]["type"] == "application/doc")
        || ($_FILES["resume"]["type"] == "application/docx")
        || ($_FILES["resume"]["type"] == "application/pdf" ))
         && (($_FILES["reference"]["type"] == "application/doc")
        || ($_FILES["reference"]["type"] == "application/docx")
        || ($_FILES["reference"]["type"] == "application/pdf"))
        && (($ext == ".pdf") || ($ext == ".doc") || ($ext == ".docx"))
        && (($ext1 == ".pdf") || ($ext1 == ".doc") || ($ext1 == ".docx"))
        &&  ($_FILES["resume"]["size"] < 400000) //accept upto 500 kb
        &&  ($_FILES["reference"]["size"] < 400000)) …
Run Code Online (Sandbox Code Playgroud)

php mysql file-upload file-type

1
推荐指数
1
解决办法
2万
查看次数

标签 统计

file-upload ×2

file-type ×1

fileapi ×1

html5 ×1

mysql ×1

php ×1