douwo1862 2016-09-20 01:16
浏览 12
已采纳

PHP无法搜索别名目录XAMPP

I have my server set up and I can send images from the htdocs/images folder. However, I want to display images from outside of the htdocs folder.

In my httpd.conf file, I created an alias, so now /myimages links to the appropriate folder on my computer. If I navigate to localhost/myimages, I get the index of myimages and it displays a listing of all my images.

Whenever I directly access the file, say

$file = "myimages/image.jpg";

It works perfectly fine, I return the image as I expect. The problem comes in when I try to look for the image instead of directly accessing it.

Whenever I try to do:

$files = scandir($dir);

Where $dir is "images" or "myimages" it just returns an error message saying no such file or directory.

My intention is to set it up so that I can search for the file I wanted by some text input from the user and serve up the file. However, it seems to be a problem that it's an alias and not actually there.

  • 写回答

1条回答 默认 最新

  • duanlaiquan8174 2016-09-20 01:30
    关注

    the alias will work for the web-server but scandir() is not using the web-server you want to set up a Symbolic link

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?