switch(strrchr(basename($lien), ".")) { case ".png": $type = "image/png"; break; case ".gif": $type = "image/gif"; break; case ".jpg": $type = "image/jpeg"; break; default: $type = "application/octet-stream"; break; } header("Content-disposition: attachment; filename=".$name); header("Content-Type: $type"); header("Content-Length: ".filesize($lien)); header('Content-Transfer-Encoding: binary'); header("Pragma: no-cache"); header("Cache-Control: must-revalidate, post-check=0, pre-check=0, public"); header("Expires: 0"); readfile($lien); ob_clean(); flush(); readfile($file); exit;
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre questionswitch(strrchr(basename($lien), ".")) { case ".png": $type = "image/png"; break; case ".gif": $type = "image/gif"; break; case ".jpg": $type = "image/jpeg"; break; default: $type = "application/octet-stream"; break; } header("Content-disposition: attachment; filename=".$name); header("Content-Type: $type"); header("Content-Length: ".filesize($lien)); header('Content-Transfer-Encoding: binary'); header("Pragma: no-cache"); header("Cache-Control: must-revalidate, post-check=0, pre-check=0, public"); header("Expires: 0"); $fp = fopen($lien, "r"); $contents = ''; while (!feof($fp)) { ob_end_flush(); ob_flush(); flush(); ob_start(); echo fread($fp, 1024); } fclose($fp);