Some time ago did a picture upload small program, today some people say JPG images can not upload. I was in the local chrome, Firefox test, found no problem, upload normal. I asked him what browser he used to be the window of the world and 360 ... I'm embarrassed. I think, is not the problem of IE? So I was in IE under the test, sure enough. The original program is as follows:
Switch ($type) {case "image/jpeg": $resultImage = Imagecreatefromjpeg ($original); imagejpeg ($resultImage, $target, $ Quality); Break;case "Image/png": $resultImage = Imagecreatefrompng ($original); Imagepng ($resultImage, $target, $quality _png); Break;case "Image/gif": $resultImage = Imagecreatefromgif ($original); Imagegif ($resultImage, $target, $quality); break ;d efault:d IE ("This file type is not supported"); Exit;}
Google later, found that the JPG format of the picture under IE does have some differences.
Upload a JPG image under IE, and then print the information for the uploaded file as follows:
Array ([name] = Bkjia.jpg[type] [image/pjpeg[tmp_name] =/tmp/phpry0loe[error] = 0[size] + 71189)
JPG format of the picture MimeType for Image/pjpeg. Since the development of Chrome or Firefox development, in the judgment is not added image/pjpeg, so that the JPG format of the image in the IE kernel browser can not be recognized.
The following is the format of each format picture in different browsers in comparison:
Firefox image/jpeg image/bmp image/gif image/pngie 6 image/pjpeg image/bmp image/gif image/x-pngie 7 image/pjpeg image/bmp Image/gif Image/x-pngie 8 image/pjpeg image/bmp image/gif image/x-png
When you pass a picture, IE will translate JPG and JPEG into image/pjpeg,png and translate it into image/x-png. And Firefox is very standard: JPG, jpeg translation into Image/jpeg,png translated into image/png.
It's OK to change the program to this.
Switch ($type) {case "image/jpeg": $resultImage = Imagecreatefromjpeg ($original); imagejpeg ($resultImage, $target, $ Quality); Break;case "Image/pjpeg": $resultImage = Imagecreatefromjpeg ($original); imagejpeg ($resultImage, $target, $quality); Break;case "Image/png": $resultImage = Imagecreatefrompng ($original); Imagepng ($resultImage, $target, $quality _png); Break;case "Image/gif": $resultImage = Imagecreatefromgif ($original); Imagegif ($resultImage, $target, $quality); break ;d efault:d IE ("This file type is not supported"); Exit;}
http://www.bkjia.com/PHPjc/752535.html www.bkjia.com true http://www.bkjia.com/PHPjc/752535.html techarticle some time ago did a picture upload small program, today some people say JPG images can not upload. I was in the local chrome, Firefox test, found no problem, upload normal. I asked him what he used ...