PHP Image Uploader - IE" pjpeg" MIME类型,无法正常工作 [英] PHP Image Uploader - IE "pjpeg" MIME type, not working
问题描述
我很难使用我的图片上传脚本,让图片在Internet Explorer中上传。我一直在谷歌寻找解决方案,并添加image / pjpegmime类型似乎适用于所有人,但我已将其添加到我的代码中,仍然无法使其工作。
I am having a hard time with my image upload script, getting the images to upload in Internet Explorer. I have been searching Google for a solution and adding the "image/pjpeg" mime type seemed to work for everyone, but I have added it to my code and still cannot get it to work.
以下是我所拥有的:
$acceptedExts = array ('jpg','jpeg');
if ( in_array($ext,$acceptedExts)
&& ( $_FILES["uploaded_file"]["type"] == "image/pjpeg"
|| $_FILES["uploaded_file"]["type"] == "image/jpeg")
&& ($_FILES["uploaded_file"]["size"] < 16000000)) {
我做错了什么?
谢谢!
推荐答案
试试 var_dump($ _ FILES ['uploaded_file'])
以确切了解IE的发送方式。它可能是 image / jpg
或完全不同的东西。但是,使用用户提供的 ['type']
字段进行验证是不好的形式。伪造这种价值是微不足道的。更好地使用服务器端方法来确定文件类型,例如 get_image_size()
或 FileInfo
库其中返回文件的真实mime类型。
Try a var_dump($_FILES['uploaded_file'])
to see exactly what IE's sending. It may be image/jpg
or something completely different. However, it's bad form to use the user-provided ['type']
field for validation. It's trivial to forge that value. Better use a server-side method to figure out file type, such as get_image_size()
or the FileInfo
library, both of which return the true mime-type of the file.
这篇关于PHP Image Uploader - IE" pjpeg" MIME类型,无法正常工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!