OVH Cloud OVH Cloud

l'eternelle question de header qui marchent pas :

1 réponse
Avatar
ShameOnMe
mes header marchaient bien pour downloader un fichier CSV, mais je
voulait qu'il s'affiche dans le navigateur MS IE, j'ai donc repompé
des header du NG, ca donne ca :

header("Pragma: public");
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header('Content-Description: File Transfer');
header('Content-Type: application/vnd.ms-excel');
header('Content-Length: ' . filesize($this->pathAndFile));
header("Content-Disposition: attachment;filename=\"{$fileName}\"");

avec :
$this->pathAndFile : chemin relatif au fichier
$fileName : nom du fichier

maintenant ca me propose toujours de le telecharger (snif) mais en plus
ca telecharge pas le bon...

au debuit mon header etait :

header('Content-Type: application/x-msexcel');
header('Content-Disposition: attachment; filename="sortie.csv"');
readfile("$this->pathAndFile");

avec sortie.csv le nom du fichier une fois DL... la ca marchait masi
l'affichait pas dans le navigateur

shame on me to times! (pour la seconde fois, je laisse les perspicaces
voir...)

1 réponse

Avatar
m-e-
"ShameOnMe" a écrit dans le message de news:

[...]
header('Content-Type: application/x-msexcel');
header('Content-Disposition: attachment;
filename="sortie.csv"');


Mettre "inline" au lieu de "attachment".

"The Content-Disposition Header Field" :
http://www.ietf.org/rfc/rfc2183.txt