PHP display/download directory files outside the webserver root

前端 未结 3 1477
礼貌的吻别
礼貌的吻别 2021-01-23 19:38

I have downloaded and added this very simple, one file, php web file explorer system(called Indexer) to my XAMPP server.

My XAMMP server is on my C: drive, but I want In

3条回答
  •  -上瘾入骨i
    2021-01-23 19:59

    You have to change your apache configuration. The problem is not the php script, the problem is the webserver (which is not able to serve files outside web root, unless you configure it to).

    Try something like this in your apache configuration:

    Alias /testalias "G:/test"
    
      Options Indexes FollowSymLinks MultiViews ExecCGI
      AllowOverride All
      Order allow,deny
      Allow from all
    
    

    This tells Apache to serve files from G:/test when you access http://localhost/testalias

    Then change your script configuration like that:

    $WebServerPath = dirname("testalias");
    

    and it should work!

提交回复
热议问题