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

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

问题描述

我想检查上传的文件是图像文件(例如 png、jpg、jpeg、gif、bmp)还是其他文件.问题是我正在使用 Uploadify 上传文件,这会更改 mime 类型并提供文本/八进制"或其他内容作为 mime 类型,无论您上传哪种文件类型.

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.

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

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

推荐答案

你可以使用 getimagesize() 对于非图像的大小返回零.

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

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

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