j'ai fait un petit script PHP qui permet de forcer le téléchargement de
fichiers de type .pdf (pour éviter qu'ils ne s'ouvrent dans le navigateur).
Voila le résumé de la procédure:
<?
// $fichier : url relative du fichier
// $named : nom du fichier
header("Content-type: application/pdf");
header("Content-Length: ".filesize($fichier));
header("Content-Disposition: inline; filename=\"$named\"");
header("Content-Transfer-Encoding: binary");
header ("Location: $fichier");
?>
Tout se passe bien sous FireFox, mais sous IE, le script propose
d'enregistrer sous le nom... du script et non pas du fichier.
Quel est le problème? le Content-Disposition?
Merci bien
--
Aide informatique: http://help-info.forumactif.com
Humour: http://www.chatfou.com
Tchattez en liberté: http://www.crazy-irc.net
switch( $file_extension ) { 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"; }
switch( $file_extension ) {
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";
}
switch( $file_extension ) { 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"; }
switch( $file_extension ) { 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"; }
switch( $file_extension ) {
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";
}
switch( $file_extension ) { 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"; }
Voila, il semblerait donc que ce ne soit pas exactement un problème de Content-Disposition mais plutôt des autres headers qui vont (ou pas) l'inhiber.
-- Aide informatique: http://help-info.forumactif.com Humour: http://www.chatfou.com Tchattez en liberté: http://www.crazy-irc.net
CrazyCat
Xavier Garreau wrote:
header ("Location: $fichier"); Ca n'irait pas mieux avec un readfile($fichier) à la place du header Location ?
Au temps pour moi, c'est bien un readfile(). En fait le script fonctionne de deux manières différentes selon que le fichier soit local ou distant, et j'ai un peu trop coupé dans les lignes :)
-- Aide informatique: http://help-info.forumactif.com Humour: http://www.chatfou.com Tchattez en liberté: http://www.crazy-irc.net
Xavier Garreau wrote:
header ("Location: $fichier");
Ca n'irait pas mieux avec un readfile($fichier) à la place du header Location ?
Au temps pour moi, c'est bien un readfile().
En fait le script fonctionne de deux manières différentes selon que le
fichier soit local ou distant, et j'ai un peu trop coupé dans les lignes :)
--
Aide informatique: http://help-info.forumactif.com
Humour: http://www.chatfou.com
Tchattez en liberté: http://www.crazy-irc.net
header ("Location: $fichier"); Ca n'irait pas mieux avec un readfile($fichier) à la place du header Location ?
Au temps pour moi, c'est bien un readfile(). En fait le script fonctionne de deux manières différentes selon que le fichier soit local ou distant, et j'ai un peu trop coupé dans les lignes :)
-- Aide informatique: http://help-info.forumactif.com Humour: http://www.chatfou.com Tchattez en liberté: http://www.crazy-irc.net