Forum » » Le coin des codeurs » » Transmettre des données dans un fichier au navigateur...
Posté : 9 févr. 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 fichier
header('!content-disposition:! attachment; filename=install.conf.php');
// Type de document, toujours mettre application/force-download
header('!content-type:! application/force-download');
header('!content-transfer-encoding:! fichier');
// La taille du fichier est obtenu par la fonction filesize
header('Content-Length: '.filesize($installconf));
// Pas de mise en cache
header('Pragma: no-cache');
header('Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0');
header('Expires: 0');
// Envoie du fichier
readfile($installconf);
unlink($installconf);
}
else
{
if(file_exists($installconf))
{
unlink($installconf);
}
echo "<br/><br/><h1 style=\"color:red\">Impossible de créer le fichier install.conf.php. Vérifiez que le dossier modules/".$ModStart."/generator/ a bien un chod 777.</h1>";
}
?>
Cet article provient de NPDS
https://www.npds.org/viewtopic.php?topic=15479&forum=5