Broken image with readfile and file_get_contents

I am trying to use a function to make this work:

<img src='login.php?image=ind_legend.jpg'>

But I can not go through the function to place the image. I went back a few steps and tried only this part of the code:

<?php
$file = "http://localhost/sales/test.jpg";
header('Content-type: image/jpeg');
readfile($file);
?>

or using this function:

echo file_get_contents($source);

but the fact is that the only thing I get is a broken image cross (IE) or nothing in Firefox.

I would be grateful for any suggestions

Thanks in advance

+5
source share
4 answers

You probably have spaces in your PHP script or UTF-8 BOMinvisibly in front of your marker <?php. Use hexeditor to find out.

, URL- http://localhost/login.php?image=ind_legend.jpg , . JPEG.

+4

ob_clean() php readfile()

+10

, , , . . php :

<?php
$file = "http://localhost/sales/test.jpg";
header('Content-type: image/jpeg');
readfile($file);
+2

http://youraddress/login.php?image=ind_legend.jpg .

, /sales/test.jpg http://wrapper readline

Finally, save the damaged image using the option "Save image as ... context menu of your browser" and try to open it using a text editor. I would not be surprised if you find an error message (if you turned them on).

0
source

All Articles