如何检查上传的文件是否是没有MIME类型的图像? [英] How to check if an uploaded file is an image without mime type?

查看:139
本文介绍了如何检查上传的文件是否是没有MIME类型的图像?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想检查上传的文件是否是一个图像文件(如PNG,JPG,JPEG,GIF,BMP)或其他文件。问题是我正在使用uploadify上传文件,这会改变MIME类型,并给出一个文本/八进制或类似的MIME类型,不管你上传的文件类型。

有没有办法检查上传的文件是否是除了使用PHP检查文件扩展名之外的图像?

解决方案

您可以使用 getimagesize() 它在非图像上返回零大小。


I'd like to check if an uploaded file is an image file (e.g png, jpg, jpeg, gif, bmp) or another file. The problem is that I'm using Uploadify to upload the files, which changes the mime type and gives a 'text/octal' or something as the mime type, no matter which file type you upload.

Is there a way to check if the uploaded file is an image apart from checking the file extension using PHP?

解决方案

You could use getimagesize() which returns zeros for size on non-images.

这篇关于如何检查上传的文件是否是没有MIME类型的图像?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆