<?php
// Make sure only files in this directory are accessible by removing slashes
$file = str_replace('/','',$_GET['file']);
$file = str_replace('\\','',$file);
// If the file doesn't exist, show an error message and leave
if(!file_exists('downloads/' . $file) {
header("HTTP/1.0 404 Not Found");
echo 'The selected file doesn\'t exist';
exit;
}
// Tell the browser to download the file
header('Content-type: application/octet-stream');
header('Content-Disposition: attachment');
// Output the file data
echo file_get_contents('downloads/' . $file);
?>