PHP display/download directory files outside the webserver root

前端 未结 3 1475
礼貌的吻别
礼貌的吻别 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条回答
  •  隐瞒了意图╮
    2021-01-23 20:14

    Let's take a look at that script:

    $Root = realpath("."); // define the directory the index should be created for (can also be located outside the webserver root)
    $AllowDownload = TRUE; // enclose file items with the anchor-tag (only makes sense when the files are in the webserver root)
    $WebServerPath = dirname(getenv("SCRIPT_NAME")); // path where the indexed files can be accessed via a http URL (only required when $AllowDownload is TRUE)
    

    Notice "only makes sense when the files are in the webserver root" and "path where the indexed files can be accessed via a http URL". Which indicates that this script was not designed to be able to download files that are outside the web server root dir.

    However, you could modify this script to be able to do that in the way that styu has noted in his answer. You could then send your changes to the author of the script.

    BTW, I tested this on my own server.

提交回复
热议问题