
Forum » » Le coin des codeurs » » Transmettre des données dans un fichier au navigateur...
Posté : 09-02-2005 10:31 
<?
$installconf = "modules/".$ModPath."/generator/install.conf.php";
$fp = fopen($installconf,"w");
if(@fwrite($fp, "Bonjour"))
{
fclose($fp);
// Pour forcer  ;le téléchargement, il faut utiliser des HEADER
// Attachement du&n bsp;fichier
header('!content-disposition: ! attachment; filename=install.conf.php');
// Type de doc ument, toujours mettre application/force-download
header('!content-type:! application/force-download');
header('!content-transfer-enc oding:! fichier');
// La taille d u fichier est obtenu par la fonction filesiz e
header('Content-Length: '.filesize($installconf));
// Pas de mise en cache
header('Pragma: no-cache ');
header('Cache-Control: n o-store, no-cache, must-revalidate, post-check=0, pre-check =0');
header('Expires: 0');
// Envoie du f ichier
readfile($installconf);
unlink($installconf);
}
else
{
if(file_exists($installconf))
{
unlin k($installconf);
}
echo "<br/><br/><h1 style=\"color:red\">Impossible de créer le fichier in stall.conf.php. Vérifiez que le dossier modules/ t>".$ModStart."/generator/ a bien un chod 777.</h1 >";
}
?>
Cet article provient de NPDS REvolution 16
https://lab.grottes-et-karsts-de-chine.org/viewtopic.php?topic=15479&forum=5