相关疑难解决方法(0)

如何在PHP中检查上传的文件类型

我用这段代码来检查图像的类型,

$f_type=$_FILES['fupload']['type'];

if ($f_type== "image/gif" OR $f_type== "image/png" OR $f_type== "image/jpeg" OR $f_type== "image/JPEG" OR $f_type== "image/PNG" OR $f_type== "image/GIF")
{
    $error=False;
}
else
{
    $error=True;
}
Run Code Online (Sandbox Code Playgroud)

但有些用户抱怨他们在上传任何类型的图片时出错,而其他一些用户则没有收到任何错误!

我想知道这是否解决了这个问题:

if (mime_content_type($_FILES['fupload']['type']) == "image/gif"){...

任何意见?

php file-upload

35
推荐指数
2
解决办法
8万
查看次数

标签 统计

file-upload ×1

php ×1