3

A similar question was asked here

Serving images from outside of document root

The solution given and accepted was using Apache Aliases.

However, does an Apache Alias of a folder just make it public as well? I would like to serve an image and maintain its invisibility in public eyes.

Does anyone know any other solutions to serving images outside of the document root besides the Alias?

Any help would be greatly appreciated.

Community
  • 1
  • 1
Irlanco
  • 769
  • 1
  • 8
  • 22
  • 1
    can you clarify: "I would like to serve an image and maintain its invisibility in public eyes" ? – Nir Alfasi Jun 30 '12 at 02:24
  • I have just answered a similar question. Would this suit your needs? http://stackoverflow.com/questions/11270409/php-use-header-for-a-specific-page/11270507#11270507 – Kris Jun 30 '12 at 02:33
  • I meant that I do not want users to see this uploads folder. That's why I am not putting this folder in the public directory. Hmm can I put an image into an img tag(src) using this method? – Irlanco Jun 30 '12 at 04:19

1 Answers1

3

You could do something like this...

<?php

// somehow assign $file from a query string or database or whatever
header("Content-length: ". filesize($file));
header("Content-type: ". mime_content_type($file));
readfile($file);
MDrollette
  • 6,887
  • 1
  • 36
  • 49