Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

page de téléchargement avec smarty

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Language: French
View previous topic :: View next topic  
Author Message
newbie_php
Smarty n00b


Joined: 11 Dec 2007
Posts: 1

PostPosted: Tue Dec 11, 2007 12:55 pm    Post subject: page de téléchargement avec smarty Reply with quote

bonjour,
je suis nouveau sur ce forum et débutant en php
Mon probleme est le suivant.

J'ai une page qui me permet de lancer le téléchargement de donnée, le code est le suivant :
Code:

{php}
header("Pragma: public");
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Cache-Control: private",false);
header("Content-Type: text/csv");
header("Content-Disposition: attachment; filename=\"nonfichier.csv\";" );
{/php}
{foreach item=col from=$colums}{$columsDef[$col].titreCol};{/foreach}

{foreach item=compte from=$comptes}
{foreach item=col from=$colums}{$compte.$col};{/foreach}

{/foreach}



Ma question est en fait un probleme avec Internet Explorer.
Quand je télécharge mon fichier j'ai la fenêtre IE qui reste à l'écran.
Comment faire pour la refermer ?
J'ai essaye de mettre une founction java dans le tpl mais cela me met des erreurs...

Comment puis je faire SVP ??
Back to top
View user's profile Send private message
Vynka
Smarty Rookie


Joined: 30 Apr 2003
Posts: 17
Location: Belgium

PostPosted: Mon Dec 24, 2007 3:10 pm    Post subject: Reply with quote

Le problème ne vient peut-être de l'ordre d'interprétation du code. Perso, je te conseillerais de lancer tes header depuis PHP et une fois lancer de faire un display de ton fichier généré.

Code:

header("Content-disposition: attachment; filename=$Fichier_a_telecharger");
header("Content-Type: application/force-download");
header("Content-Transfer-Encoding: $type\n"); // Surtout ne pas enlever le \n
header("Content-Length: ".filesize($chemin . $Fichier_a_telecharger));
header("Pragma: no-cache");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0, public");
header("Expires: 0");

$smarty->display('mon_template_de_fichier.tpl'); exit(0);

_________________
Au pays des Gloups!
http://www.wishlist.lu
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Language: French All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP