本文介绍了如何检查文件是否为图像?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我可以检查某个文件是否是图像吗?如何在PHP中执行此操作?
Can I check whether or not a certain file is an image? How can do this in PHP?
如果文件不是图像,我想发出警告消息。
If the file is not an image, I want to give an alert message.
推荐答案
除,你可以使用
找到正确的签名后,将返回相应的常量值,否则返回值为FALSE。返回值与getimagesize()在索引2中返回的值相同,但exif_imagetype()的速度要快得多。
When a correct signature is found, the appropriate constant value will be returned otherwise the return value is FALSE. The return value is the same value that getimagesize() returns in index 2 but exif_imagetype() is much faster.
对于这两个函数,如果文件未确定为图像,则返回FALSE。
For both functions, FALSE is returned if the file is not determined to be an image.
这篇关于如何检查文件是否为图像?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!