PHP Header - Content-type: image/jpeg - Not working for Internet Explorer

后端 未结 4 1209
别跟我提以往
别跟我提以往 2021-01-12 05:41

We all hate Internet Explorer when building HTML templates, or modifying websites. Well I recently built a PHP image script to hide the location of the URL. It works fine fo

相关标签:
4条回答
  • 2021-01-12 06:01

    Set the content length header.

    header("Content-Length: " . filesize($imagepath));
    
    0 讨论(0)
  • 2021-01-12 06:08

    Internet explorer uses the mime type image/pjpeg. You use pjpeg for IE and jpeg for other browsers.

    header("Content-Type: image/pjpeg");
    

    Source: image/pjpeg and image/jpeg

    0 讨论(0)
  • 2021-01-12 06:14

    The Content-Type header name is written with an uppercase T. I am not sure if that is the issue, but some browsers might not recognize the Content-Type header when it is written with a lowercase t. Thus, you should use:

    header("Content-Type: image/jpeg");
    

    Something else that might be a problem, is when you try to display an image that is not a jpeg, but a png or gif, while you give the image/jpeg content-type header. So, you should ensure that you give the correct content-type to the browser.

    0 讨论(0)
  • 2021-01-12 06:16

    I think I know what the problem is.

    Internet Explorer expects you to use image/jpeg and not image/jpg.

    Try this:

    Header("Content-Type: image/jpeg"); 
    

    All browsers accept this format, and you won't have to worry anymore.

    0 讨论(0)
提交回复
热议问题