我用PHP提交文件一个图片,上传后判断文件类型,IE 提交为什么格式为image/jpg?
我后台判断是image/jpeg和image/pjpeg我用IE为什么会有image/jpg格式,网上查了很多没找到
array(5) { ["name"]=> string(10) "982733.jpg" ["type"]=> string(9) "image/jpg" ["tmp_name"]=> string(25) "C:\WINDOWS\TEMP\php2E.tmp" ["error"]=> int(0) ["size"]=> int(19528) } 

解决方案 »

  1.   

    做了个测试,同一个程序,上传同一个图片,得到如下结果:
    IE6             [type] => image/pjpeg
    FF3.0.7         [type] => image/jpeg
    SARARI4.0.4     [type] => image/jpeg
    GOOGLE 4.1.249  [type] => image/jpeg
    OPERA 10.10     [type] => image/jpeg
      

  2.   

    注意php手册关于$_FILES['userfile']['type'] 的说明The mime type of the file, if the browser provided this information. An example would be "image/gif". This mime type is however not checked on the PHP side and therefore don't take its value for granted. 不要想当然的认为就一定有这个值,只是浏览器给出的,也可以不给出,php并不检查
      

  3.   

    我采用的是IE浏览器现在升级成IE7还是image/jpg,怎么回事呢
      

  4.   

    浏览器给出是可以改变的吧,如何更改浏览器的MIME
      

  5.   

    以前我用程序上传是image/pjpeg,可今天不知道怎么了总是image/jpg
      

  6.   

    都说了php并不检查这个值,所以你也不应该通过它来判断文件的类型
    要想检查图片类型,可以使用exif_imagetype或getimagesize函数
      

  7.   


    所以你应该自己来取定 mime
    $info = getimagesize($_FILES['file']['tmp_name']);
    $_FILES['type'] = $info['mime'];