Voici mon code :
<?
header('Content-type: text/html; charset=utf-8');
// To recovery the beginning of the documentation path (ex: d:\documents\)
$sql="SELECT Value FROM conf WHERE Name='DocumentationPath'";
$req = mysqli_query($db,$sql) or die('SQL Error !<br>'.$sql.'<br>'.mysqli_error($db));
$row = mysqli_fetch_row($req);
$dir = $row[0];
// then end of the path with the file (ex:notes\rapport.doc)
$file = $_GET["file"];
ob_start();
//download
header("Content-Type: application/force-download; name=\"".basename($dir.$file)."\"");
header("Content-Transfer-Encoding: binary");
header("Content-Length: ".filesize($dir.$file));
header("Content-Disposition: attachment; filename=\"".basename($dir.$file)."\"");
header("Expires: 0");
header("Cache-Control: no-cache, must-revalidate");
header("Pragma: no-cache");
readfile($dir.$file);
exit();
$dl_file = ob_get_contents();
ob_end_clean();
echo $dl_file;
?>