简体   繁体   中英

Http request to php stream image

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.

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' />

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM