Hello and welcome to beautiful Jun Blog.

Archive for 七月 14th, 2008

PHP判断上传文件是否是图片

Tags:, , , .

项目中刚用到,简单一句,记下来

  1. $isImage = preg_match(/^image\//i,$fileType)?true:false;

很多朋友在判断文件格式是看文件后缀,但是这个方法很危险,容易被注入病毒。因此正确的方式是检查文件的 MIME 类型。

Posted on 14 七月 '08 by admin, under php. No Comments.