更新时间:2023-11-25 17:35:16
您应该打开文件并查看其中的内容,而不是尝试通过扩展名检测文件类型.
Instead of try to detect the file type by extension, you should open the file and see what's in it.
$allowed_types = array(IMAGETYPE_GIF,IMAGETYPE_JPEG,IMAGETYPE_PNG);
if (in_array(exif_imagetype($_FILES["upload_picture"]["tmp_name"]), $allowed_types)){
//is either jpeg, png or gif
}