Pb : forcer le telechargmeent JPG
$id_carte=$_REQUEST['id_carte']; | |
$type=$_REQUEST['type']; | |
$extension=$_REQUEST['extention']; | |
$extension=strtolower ($extension); | |
$name = $id_carte."_a".$type.".".$extension; | |
$dossier="/cartes/$id_carte/"; | |
// vérifie l'existence et l'accès en lecture au fichier | |
$filename = dirname(__FILE__).$dossier.$name; | |
if (!is_file($filename) || !is_readable($filename)) { | |
header("HTTP/1.1 404 Not Found"); | |
exit; | |
} | |
$size = filesize($filename); | |
// désactivation compression GZip | |
if (ini_get("zlib.output_compression")) { | |
ini_set("zlib.output_compression", "Off"); | |
} | |
// désactive la mise en cache | |
header("Cache-Control: no-cache, must-revalidate"); | |
header("Cache-Control: post-check=0,pre-check=0"); | |
header("Cache-Control: max-age=0"); | |
header("Pragma: no-cache"); | |
header("Expires: 0"); | |
// force le téléchargement du fichier avec un beau nom | |
header("Content-Type: application/force-download"); | |
//header("Content-Transfer-Encoding: $type\n"); | |
header("Content-Disposition: attachment; filename=$name"); | |
// indique la taille du fichier à télécharger | |
header("Content-Length: ".$size); | |
// envoi le contenu du fichier | |
readfile($filename); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment