How to change content type in php?

前端 未结 2 1122
醉话见心
醉话见心 2020-12-16 11:51

I have an image, but it keep doesn\'t display. I check the image properties (right-click and chose properties), and the I found the \"type\" is text/html not JPEG image. Is

2条回答
  •  甜味超标
    2020-12-16 12:13

    Sounds like the image was generated by some kind of server-side script. If it was generated by a PHP script that you have access to, just include a call to header(), like this:

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

    Make sure to call header() before outputting anything—even a blank line or stray space that was accidentally output will cause header() to fail (usually it's best if you put your call to header() at the beginning of the script).

    If you don't have access to the script that generated the image, then you're out of luck, I think.

提交回复
热议问题