dongyong8098 2017-04-13 01:04
浏览 24
已采纳

Http请求到php流图像

I have a php file, when you open it, a picture is going to be downloaded and opened. Here is my code:

header('Content-type: image/jpeg');
$stream = fopen('php://output', 'w'); // Stream to browser like with echo
$MadelineProto->download_to_stream($messageMediaPhoto, $stream);

It's ok when you open directly. But when I send an ajax request to the page, I get some long strange characters. (I want to display the image in html src)

any idea would be appreciated.

  • 写回答

1条回答 默认 最新

  • drcrc28428 2017-04-13 19:35
    关注

    You need to add your php file to the src attribute of the image tag. For example if your php file is called image.php, then you can use the following html code to display the image:

    <img src='image.php' width='image-width-in-px' height='image-height-in-px' />
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
编辑
预览

报告相同问题?

手机看
程序员都在用的中文IT技术交流社区

程序员都在用的中文IT技术交流社区

专业的中文 IT 技术社区,与千万技术人共成长

专业的中文 IT 技术社区,与千万技术人共成长

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

客服 返回
顶部