Irlanco
Irlanco

Reputation: 779

Displaying images from outside the site root

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.

Upvotes: 3

Views: 4258

Answers (1)

MDrollette
MDrollette

Reputation: 6927

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);

Upvotes: 3

Related Questions