1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
| switch(strrchr(basename($PC_Fichier), ".")) {
case ".zip": $LC_Type = "application/zip"; break;
case ".pdf": $LC_Type = "application/pdf"; break;
case ".txt": $LC_Type = "text/plain"; break;
default: $LC_Type = "application/octet-stream"; break;
}
header("Content-disposition: attachment; filename=" . BaseName($PC_Fichier));
header("Content-Type: application/force-download");
header("Content-Transfer-Encoding: LC_Type\n"); // Surtout ne pas enlever le \n
header("Content-Length: " . FileSize($PC_Fichier));
header("Pragma: no-cache");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0, public");
header("Expires: 0");
readfile($PC_Fichier);
header('Location: index.php?pg=me&mess=LG'); |
Partager