0

I just learned about "how to add image outside of web root". I have done everything as mentioned. But the image is not displaying. Here's the code in the file called get_image.php. and the Directory structure:

home.php

`...
<body>
   <img src="/get_image.php?image=myimg.jpg" width="100" height="100"/>
</body
...`

I have checked is_readable() and file_exists() seems ok.

app
  |_upload_dir
      |_myimg.jpg
      |_ myimg2.png
Public_html
  |_asset_dir
  |_get_image.php
  |_ home.php

get_image.php

<?php
  $mime_type = mime_content_type("../app/upload_dir/{$_GET['image']}");
  header('Content-Type: '.$mime_type);

  readfile("../app/upload_dir/{$_GET['image']}");
?>

So why the image is not displaying??

Bipul Roy
  • 506
  • 2
  • 7
  • 18

1 Answers1

-1

Problem solved :) . Well... I forgot to include a file that had the IMAGE_PATH constant which was holding the path to the upload_dir.

Bipul Roy
  • 506
  • 2
  • 7
  • 18