Ajax and returning image created by PHP GD

前端 未结 3 1820
囚心锁ツ
囚心锁ツ 2021-01-21 15:54

I have a PHP script that generates an image with PHP GD. After it generates the image, it saves it, and send this output when called by Ajax:

imagejpeg($img_data         


        
3条回答
  •  盖世英雄少女心
    2021-01-21 16:14

    You should modify the header before doing the echo $img_data;

    header("Content-Type: image/jpeg");
    header("Content-Length: " .sizeof($img_data));
    

提交回复
热议问题