0

我有一些图像单独保存在文档根目录之外的文件夹中。

我编写了一个程序来压缩这些图像 ZipArchive();

php 文件在我的文档根目录的子文件夹中运行。

我只是将外部图像路径作为数组提供并将其传递给 zip 对象并且工作正常

$imgList = array(
    '/OUTSIDEFOLDER/img1.jpg',
     '/OUTSIDEFOLDER/img2.jpg'
);

我用来显示图像的相同路径

<img src='/OUTSIDEFOLDER/img1.jpg'>

这是行不通的。我做错了什么。是图像来源的限制还是

我必须查看任何配置 htaccess 设置

4

1 回答 1

2

The document root specifies what parts of your server's file system is available to be served up by the webserver.

If you could just specify any path you wanted, anyone could steal anyfile they wanted from your server, etc..

To serve something from outside the document root, you'll have to

  1. create an Apache alias that points to the file, so it effectively becomes "inside the document" root
  2. Create a filesystem symlink inside your document root that points to the external file, and make sure the webserver allows such symlinks and follows them
  3. Use a script (e.g. php) to serve up the file.
于 2012-04-12T18:04:22.867 回答