1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
|
/******************************************************* * Déclaration de la fonction *******************************************************/
/** * La fonction force le téléchargement d'un fichier *
* @author : Hugo HAMON
* @param : string $nom nom du fichier
* @param : string $situtation emplacement sur le serveur web
* @param : integer $poids poids du fichier en octets * @return : void **/
function forcerTelechargement($nom, $situation, $poids) {
header('Content-Type: application/octet-stream');
header('Content-Length: '. $poids);
header('Content-disposition: attachment; filename='. $nom);
header('Pragma: no-cache');
header('Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0');
header('Expires: 0'); readfile($situation); exit(); }
/******************************************************* * Appel de la fonction *******************************************************/
forcerTelechargement(fichier.pdf', './pdf/fichier.pdf', 5482000); ?> |
Partager