Je développe un site sous easyphp installé sur un xp pro. J'essaie de faire un download d'un fichier temporaire mais je me heurte systématiquement à un message d'erreur.
Jai deux fichier, 1 nommé seltrac.php qui crée le fic temporaire et fait appel au second fichier download.php.
le code du seltrac.php (pour ce qui nous intéresse) :
CODE
$tmpfname = tempnam ("C:\Program Files\EasyPHP1-8\www", "fic");
$tmp=fopen($tmpfname, "w");
fwrite(écriture des rens. dans le fic)
fclose($tmp);
echo "<tr>\n";
echo "<td width='50%' align=center><a href='download.php?dwn=$tmpfname&chemin=C:\Program Files\EasyPHP1-8\www\'> Télécharger votre sélection </a></td>\n";
echo "</tr>\n";
$tmp=fopen($tmpfname, "w");
fwrite(écriture des rens. dans le fic)
fclose($tmp);
echo "<tr>\n";
echo "<td width='50%' align=center><a href='download.php?dwn=$tmpfname&chemin=C:\Program Files\EasyPHP1-8\www\'> Télécharger votre sélection </a></td>\n";
echo "</tr>\n";
Le code du download.php :
CODE
<?php
switch(strrchr(basename($dwn), "."))
{
case ".gz": $type = "application/x-gzip"; break;
case ".tgz": $type = "application/x-gzip"; break;
case ".zip": $type = "application/zip"; break;
case ".pdf": $type = "application/pdf"; break;
case ".png": $type = "image/png"; break;
case ".gif": $type = "image/gif"; break;
case ".jpg": $type = "image/jpeg"; break;
case ".txt": $type = "text/plain"; break;
case ".htm": $type = "text/html"; break;
case ".html": $type = "text/html"; break;
default: $type = "application/octet-stream"; break;
}
header("Content-disposition: attachment; filename=$dwn");
header("Content-Type: application/force-download");
header("Content-Transfer-Encoding: $type\n");
header("Content-Length: ".filesize($chemin . $dwn));
header("Pragma: no-cache");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0, public");
header("Expires: 0");
readfile($chemin . $dwn);
?>
switch(strrchr(basename($dwn), "."))
{
case ".gz": $type = "application/x-gzip"; break;
case ".tgz": $type = "application/x-gzip"; break;
case ".zip": $type = "application/zip"; break;
case ".pdf": $type = "application/pdf"; break;
case ".png": $type = "image/png"; break;
case ".gif": $type = "image/gif"; break;
case ".jpg": $type = "image/jpeg"; break;
case ".txt": $type = "text/plain"; break;
case ".htm": $type = "text/html"; break;
case ".html": $type = "text/html"; break;
default: $type = "application/octet-stream"; break;
}
header("Content-disposition: attachment; filename=$dwn");
header("Content-Type: application/force-download");
header("Content-Transfer-Encoding: $type\n");
header("Content-Length: ".filesize($chemin . $dwn));
header("Pragma: no-cache");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0, public");
header("Expires: 0");
readfile($chemin . $dwn);
?>
les messages d'erreur :
CODE
Notice: Undefined variable: dwn in c:\program files\easyphp1-8\www\download.php on line 2
Notice: Undefined variable: dwn in c:\program files\easyphp1-8\www\download.php on line 17
Warning: Cannot modify header information - headers already sent by (output started at c:\program files\easyphp1-8\www\download.php:2) in c:\program files\easyphp1-8\www\download.php on line 17
../..
Notice: Undefined variable: chemin in c:\program files\easyphp1-8\www\download.php on line 24
Notice: Undefined variable: dwn in c:\program files\easyphp1-8\www\download.php on line 24
Notice: Undefined variable: dwn in c:\program files\easyphp1-8\www\download.php on line 17
Warning: Cannot modify header information - headers already sent by (output started at c:\program files\easyphp1-8\www\download.php:2) in c:\program files\easyphp1-8\www\download.php on line 17
../..
Notice: Undefined variable: chemin in c:\program files\easyphp1-8\www\download.php on line 24
Notice: Undefined variable: dwn in c:\program files\easyphp1-8\www\download.php on line 24
merci d'avance pour le coup de main et pour l'explication qui ira avec (j'aime bien me couché moins bête que je me suis levé)
<edit=Dan: merci d'utiliser les balises CODE et CODEBOX pour les citations de messages. J'ai supprimé une partie de tes erreurs, parce que ce n'est que la première qui compte dans ton cas >