Bonjour,

J'ai testé votre script (cf FAQ) pour forcer le téléchargement d'un fichier uploadé.

http://php.developpez.com/faq/?page=..._forcedownload

Cela dit il ne fonctionne pas

Ce que j'ai fait:

-J'ai placé mon fichier dans un répertoire de mon site :
http://monsite.com/antipubs/Pubs.xml

- J'ai crée le script (en .php) pour forcer un téléchargement, placé dans le même répertoire que le fichier:

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
<?php
$full_path = 'antipubs'; // chemin système (local) vers le fichier
$file_name = basename($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; 
 
?>


-> En allant sur http://monsite.com/antipubs/Pubs.xml, mon navigateur lis ce fichier, au lieu de me proposer de le télécharger...

Comment faire svp ?
Merci de vos aides