Home  >  Article  >  Backend Development  >  文件上传类型限制解决办法

文件上传类型限制解决办法

WBOY
WBOYOriginal
2016-06-13 10:18:23832browse

文件上传类型限制
if ((($_FILES["file"]["type"] == "image/gif")
|| ($_FILES["file"]["type"] == "image/jpeg")
|| ($_FILES["file"]["type"] == "image/pjpeg"))

这个是图片限制
那限制RAR ZIP
text doc的文件类型怎么写?

------解决方案--------------------
那你得先收集你要限制的文件的mime类型。
ZIP的MIME类型用application/x-zip-compressed 
RAR的MIME类型用application/octet-stream
text的MIME类型有 text/plain
搜到个列表 http://www.wilf.cn/post/MIME_type.html
------解决方案--------------------
http://www.wilf.cn/post/MIME_type.html

这个好,顶一个

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn