-2

I need to create a php file that return a JPEG image. I wrote this code but it doesn't work:

<?php
header('Content-type: image/jpeg;');
$p = 'http://....file.jpeg';
$a = file_get_contents('$p');
echo $a;
?>

What's wrong? I think that it is too simple

img.simone
  • 580
  • 4
  • 9
  • 22

2 Answers2

2

You could simply use a <img> tag.

 <?php 
    $src = 'file.jpeg';
 ?>

 <img src='<?php echo $src ?>'>

If this is not the functionality you looking for take a look at how to Show image using file_get_contents.

Community
  • 1
  • 1
Marc Barbeau
  • 785
  • 8
  • 21
1

remove the single quotes:

<?php
header('Content-type: image/jpeg;');
$p = 'http://....file.jpeg';
$a = file_get_contents($p);
echo $a;
?>
DoppyNL
  • 1,315
  • 1
  • 13
  • 22