1 - fonction PHP - servir un fichier avec headers corrects
function serveFile($path){
if (is_file($path)){
$mime=mime_content_type($path);
header('Content-type: '.$mime.'; charset=utf-8');
header('Content-Transfer-Encoding: binary');
header('Content-Disposition: filename="'.tools::basename($path).'"');
header('Content-Length: '.filesize($path));
readfile($path);
exit;
}
header("HTTP/1.1 404 Not Found");
exit('404 - Not Found (╯°□°)╯︵ ┻━┻');
}