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.

图片转代码服务由CSDN问答提供 功能建议

我设置了服务器,可以从htdocs / images文件夹发送图像。 但是,我想显示来自htdocs文件夹外部的图像。

在我的httpd.conf文件中,我创建了一个别名,所以现在/ myimages链接到我计算机上的相应文件夹。 如果我导航到localhost / myimages,我会获得myimages的索引并显示我所有图像的列表。

每当我直接访问该文件时,请说 \ n

  $ file =“myimages / image.jpg”; 
   
 
 

它工作得很好,我按照预期返回图像。 当我尝试查找图像而不是直接访问图像时,会出现问题。

每当我尝试这样做时:

  $ files = scandir($ dir); 
    
 
 

如果$ dir是“images”或“myimages”,它只会返回一条错误消息,说明没有这样的文件或目录。

我的目的是设置它 我可以通过用户的一些文本输入搜索我想要的文件并提供文件。 但是,这似乎是一个问题,它是别名而不是实际存在。

  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 收藏
  • 邀请回答

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

    评论
    解决 无用
    打赏 举报

相关推荐 更多相似问题