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

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

报告相同问题?

悬赏问题

  • ¥15 关于无人驾驶的航向角
  • ¥15 keil的map文件中Image component sizes各项意思
  • ¥30 BC260Y用MQTT向阿里云发布主题消息一直错误
  • ¥20 求个正点原子stm32f407开发版的贪吃蛇游戏
  • ¥15 划分vlan后,链路不通了?
  • ¥20 求各位懂行的人,注册表能不能看到usb使用得具体信息,干了什么,传输了什么数据
  • ¥15 Vue3 大型图片数据拖动排序
  • ¥15 Centos / PETGEM
  • ¥15 划分vlan后不通了
  • ¥20 用雷电模拟器安装百达屋apk一直闪退