0

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.

Vahid Najafi
  • 4,654
  • 11
  • 43
  • 88

1 Answers1

1

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' />
Nadir Latif
  • 3,690
  • 1
  • 15
  • 24
  • Yes, it's a good solution. But I was wondering if there is a way to get the image as base64_encoded format. Because In this case I can't show any spinner or specially Angular loading bar. Btw thanks. – Vahid Najafi Apr 14 '17 at 12:45
  • You can get the image in base64 encoded format. An example is: Embedded Image. See this related post: http://stackoverflow.com/questions/1207190/embedding-base64-images – Nadir Latif Apr 15 '17 at 04:13