如何检查上传的文件是否是没有MIME类型的图像? [英] How to check if an uploaded file is an image without mime type?
本文介绍了如何检查上传的文件是否是没有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屋!
查看全文