显示站点根目录外部的图像

时间:2012-06-30 02:20:55

标签: php html

这里也提出了类似的问题

Serving images from outside of document root

给出和接受的解决方案是使用Apache Aliases。

但是,文件夹的Apache别名是否也公开?我想提供一个形象,并在公众眼中保持其隐形。

除Alias之外,有没有人知道在文档根目录之外提供图像的任何其他解决方案?

非常感谢任何帮助。

1 个答案:

答案 0 :(得分:3)

你可以这样做......

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