Note that there are some explanatory texts on larger screens.

plurals
  1. POPHP display/download directory files outside the webserver root
    primarykey
    data
    text
    <p>I have downloaded and added this very simple, one file, php web file explorer system(called <a href="http://tbmnet.de/tbmnet.php?content=php_indexer" rel="nofollow">Indexer</a>) to my XAMPP server.</p> <p>My XAMMP server is on my C: drive, but I want Indexer to display a directory on my G: drive. But when I change (what I think are) the right configuration variables, it doesn't work properly.</p> <p>Here is the code I think is to do with the problem:</p> <pre><code>// configuration $Root = realpath("G:/test"); $AllowDownload = TRUE; $WebServerPath = dirname("G:/test"); </code></pre> <p>and later on in the code...</p> <pre><code>elseif ($AllowDownload) { echo "&lt;a href=\"http://".getenv("SERVER_NAME").$WebServerPath."/$rel_path".$item["filename"]."\"&gt;".$item["name"]."&lt;/a&gt;"; } </code></pre> <p>This is what happens: The script <i>does</i> correctly display the contents of the "test" directory on the G: drive, but when I click the filename, to download/view the file, the link is broken because the php constructs the link wrong (I suppose). The link looks like this: http://localhostg//[name of file].</p> <p>Would you know how to solve this problem?</p> <p>This script works perfectly if I change the configuration variables so it displays the contents of a relative subdirectory. And it also says $Root variable can be located outside the webserver root. </p> <p>Also, even though clicking the link doesn't work, right-clicking and selecting "Save Target As" allows me to save/download the file.</p> <p>(Feel free to ask if you need more information) :)</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload