Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Your web server can not see the files outside the DocRoot, so it can not serve the files via the browser with direct links. You need to print their contents into the browser with <a href="http://php.net/manual/en/function.readfile.php" rel="noreferrer"><code>readfile()</code></a> with the headers properly set.</p> <p>To make this work, you need to change the configuration in indexer.php:</p> <pre><code>// this way it works with accentuated letters in Windows $Root = utf8_decode("G:\test"); // 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) // you need to place download.php in the same directory as indexer.php $WebServerPath = dirname($_SERVER['SCRIPT_NAME']) . "/download.php?path="; // path where the indexed files can be accessed via a http URL (only required when $AllowDownload is TRUE) </code></pre> <p>And you have to place a new file called <code>download.php</code> in the same directory as <code>indexer.php</code>, with this content:</p> <pre><code>&lt;?php // it must be the same as in indexer.php $Root = utf8_decode("G:\test"); function checkFileIsInsideRootDirectory($path, $root_directory) { $realpath = realpath($path); if (!file_exists($realpath)) die("File is not readable: " . $path); // detects insecure path with for example /../ in it if (strpos($realpath, $root_directory) === false || strpos($realpath, $root_directory) &gt; 0) die("Download from outside of the specified root directory is not allowed!"); } function forceDownload($path) { $realpath = realpath($path); if (!is_readable($realpath)) die("File is not readable: " . $path); $savename = (basename($path)); header("Pragmaes: 0"); header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); header("Cache-Control: private", false); header("Content-type: application/force-download"); header("Content-Transfer-Encoding: Binary"); header("Content-length: " . filesize($path)); header("Content-disposition: attachment; filename=\"$savename\""); readfile("$path"); exit; } if (!isset($_GET['path'])) die("Path not specified!"); $fullPath = $Root . $_GET['path']; checkFileIsInsideRootDirectory($fullPath, $Root); forceDownload($fullPath); </code></pre>
    singulars
    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. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      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