I am trying to make a php script to load image and display it depending on $_GET paramters.
I want to use this later to load image into my mobile application(Android).
The problem is I cannot make image to display. I use the code below:
header("Content-Type: image/jpeg");
readfile($path);
But when I open page in firefox I get error:
Image cannot be displayed because it contains errors.
What is more I tried different approach and I can get image display in html code(I dont want this - it requires to remove headers in java android - but it proves that path is correct)
echo '<img src="data:image/jpeg;base64,'.base64_encode(file_get_contents($path) ).'"/>
What am I doing wrong? Any ideas? Thanks in advance.