J'ai testé un script pour forcer le téléchargement d'un fichier uploadé.
http://php.developpez.com/faq/?page=fic ... cedownload
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 : Tout sélectionner
<?php
$full_path = '/antipubs/Pubs.xml'; // 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