Home > Backend Development > PHP Tutorial > 限制上传文件类型为EXCEL?解决思路

限制上传文件类型为EXCEL?解决思路

WBOY
Release: 2016-06-13 13:51:48
Original
2315 people have browsed it

限制上传文件类型为EXCEL?


用这个 if($_FILES['excel_file']['type'] != 'application/vnd.ms-excel') 好像不行


可能是EXCEL版本的问题 , 如何解决呀




------解决方案--------------------
$imgtype = strtolower(strrchr($_FILES['excel_file']['name'],".")); //取得扩展名
if($imagetype=='.xls' || $imagetype=='.xlsx'){ //可能还有其他的格式。请自行加上。
.........
}else{
....... 
}
------解决方案--------------------
5楼那个方法很好,我一直在用
以前研究过,发现有一些格式在不同浏览器里显示的MIME类型居然是不一样的。。。甚至是直接就为空
判断后缀名是最直接的

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template