-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
  • 632
  • 6
  • 10
  • 23

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
  • 826
  • 10
  • 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,415
  • 1
  • 14
  • 24