PHP Image Uploader - IE “pjpeg” MIME type, not working

寵の児 提交于 2019-12-13 21:27:58

问题


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.

Here is what I have:

$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)) {

Am I doing anything wrong?

Thanks!


回答1:


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.



来源:https://stackoverflow.com/questions/6387765/php-image-uploader-ie-pjpeg-mime-type-not-working

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!