Bonjour,
je tente de forcer un téléchargement de fichier, mais ça se traduit par un warning incompréhensible.
Le code appelé :
telecharger_vieilles.php :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6 if ($handle = opendir('../sauvegarder/essai')) { while (false !== ($file = readdir($handle))) if (($file!='.')&&($file!='..')) { echo '<a href="telecharger_vieilles.php?nom_file='.$file.'">'.$file."</a><br>"; }}
Le premier warning (il y en a une cascade) :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26 <?php $nom_file=$_GET['nom_file']; // code pour forcer un téléchargement $full_path = "essai/".$nom_file; $full_path="http://villarddelanspatinage.fr/maj/sauvegarder/".$full_path; $file_name=$full_path; ini_set('zlib.output_compression', 0); $date = gmdate(DATE_RFC1123); header('Pragma: public'); header('Cache-Control: must-revalidate, pre-check=0, post-check=0, max-age=0'); header('Content-Tranfer-Encoding: none'); header('Content-Length: '.filesize($full_path)); header('Content-MD5: '.base64_encode(md5_file($full_path))); header('Content-Type: application/octetstream; name="'.$file_name.'"'); header('Content-Disposition: attachment; filename="'.$file_name.'"'); header('Date: '.$date); header('Expires: '.gmdate(DATE_RFC1123, time()+1)); header('Last-Modified: '.gmdate(DATE_RFC1123, filemtime($full_path))); readfile($full_path); exit; // nécessaire pour être certain de ne pas envoyer de fichier corrompu ?>
(Alors que ce fichier existe)
Code : Sélectionner tout - Visualiser dans une fenêtre à part Warning: filesize() [function.filesize]: Stat failed for http://villarddelanspatinage.fr/maj/sauvegarder/essai/cadre72.gif (errno=2 - No such file or directory) in /homez.309/villardd/www/maj/vieillessauvegar/telecharger_vieilles.php on line 15
A votre avis, qu'est-ce qui cloche ?
Partager