<?php //print_r($_GET); $chemin = $_GET['nom_fichier']; $fichier = basename($chemin); if (file_exists($chemin)) { //echo 'yes' ; header('Content-disposition: attachment; filename="' . $fichier . '"'); header('Content-Type: application/force-download'); header('Content-Transfer-Encoding: binary'); header('Content-Length: '. filesize($chemin)); header('Pragma: no-cache'); header('Cache-Control:no-store, no-cache, must-revalidate, post-check=0, pre-check=0'); header('Expires: 0'); readfile($chemin); } else { echo 'le fichier "' . $fichier . '" n\'existe pas. Veuillez-nous excusez pour le désagrément.chemin: '.$chemin; } ?>
<?php print_r($_GET); if(isset($_GET['nom_fichier'])){ echo $file=urldecode($_GET['nom_fichier']); $type =$_GET['type_fichier']=''; $rep="./"; /*a personnaliser*/ if (($file != "") && (file_exists( $rep . basename($file)))) { $size = filesize("./" . basename($file)); header("Content-Type:application/force-download; name="" . basename($file) . """); header("Content-Transfer-Encoding: binary"); header("Content-Length: $size"); header("Content-Disposition: attachment; filename="" . basename($file) . """); header("Expires: 0"); header("Cache-Control: no-cache, must-revalidate"); header("Pragma: no-cache"); readfile( $rep . basename($file)); exit(); } }else{ echo 'verifier url'; } ?> <!-- $filename = (isset($_GET['titre'])) ? rawurldecode($_GET['titre']) : ''; //$filename = $_GET['file']; // required for IE, otherwise Content-disposition is ignored if(ini_get('zlib.output_compression')) ini_set('zlib.output_compression', 'Off'); // addition by Jorg Weske $file_extension = strtolower(substr(strrchr($filename,"."),1)); if( $filename == "" ) { echo "<html><title>eLouai's Download Script</title> ERROR: download file NOT SPECIFIED. USE force-download.php?file=filepath</html>"; exit; } elseif ( ! file_exists( 'files/'.$filename ) ) { echo "<html><title>eLouai's Download Script</title> ERROR: File not found. USE force-download.php?file=filepath</html>"; exit; } else{ switch( $file_extension ) { case "mp3": $ctype="application/mp3"; break; /* case "pdf": $ctype="application/pdf"; break; case "exe": $ctype="application/octet-stream"; break; case "zip": $ctype="application/zip"; break; case "doc": $ctype="application/msword"; break; case "xls": $ctype="application/vnd.ms-excel"; break; case "ppt": $ctype="application/vnd.ms-powerpoint"; break; case "gif": $ctype="image/gif"; break; case "png": $ctype="image/png"; break; case "jpeg": case "jpg": $ctype="image/jpg"; break; */ default: $ctype="application/force-download"; } header("Pragma: public"); // required header("Expires: 0"); header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); header("Cache-Control: private",false); // required for certain browsers header("Content-Type: $ctype"); // change, added quotes to allow spaces in filenames, by Rajkumar Singh header("Content-Disposition: attachment; filename="".basename($filename)."";" ); header("Content-Transfer-Encoding: binary"); header("Content-Length: ".filesize($filename)); readfile('files/'.$filename); exit('BonNE écoute !'); } ?> -->
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre question