forcer un téléchargement d'une image

Mammouth du PHP | 1967 Messages

23 janv. 2006, 22:21

Bonjour à tous

Je me suis mis au php mais j'ai récupéré quelque script javascript tout fait que je tente de mettre à ma sauce.

Mais voilà un probléme se pose à moi .

Il s'agit d'une fenètre popup qui sert a comptabiliser mes downloads.
la page php l'appelle avec le nom du fichier à télécharger en GET
Tout marche bien pour des fichier zip mais comment puis je faire pour obliger un téléchargement de fichier pdf ou jpg.gif qui eux s'ouvre dans mon popup.

voici le code
<html>

<head>
<title>Téléchargement</title>
<meta name="robots" content="noindex, nofollow">
<script language="JavaScript">
function MM_goToURL() { //v3.0
  var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
  for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
}
</script>
<script language="javascript">
setTimeout("self.close();",100000000000)
</script>
</head>

<body bgcolor="#000000" text="#FFFFFF"
onLoad="MM_goToURL('parent','<?php $name_file = trim($_GET[file]);echo "/php/Fichier/",$name_file; ?>');return document.MM_returnValue">

<table width="24%" border="0" height="97">
  <tr>
    <td height="85" width="67%"><div align="center"><font size="-1"
    face="Verdana, Arial, Helvetica, sans-serif" color="#FFFF00"><b><p>Téléchargement en
    cours.</p></b></font><br>
    Fermeture auto de cette fenêtre. <br>
<?php echo $name_file; ?></p>
    </div></td>
  </tr>
</table>

<p>&nbsp;</p>
</body>
</html>
<?php
$name_temp = $_GET[file].".txt";
if ($_GET[file] != "")
{
	@$fh = fopen("$name_temp", "r+");
		while (@!feof($fh))
		{
	@		$ligne = fgets($fh);
			if ($ligne==""){continue;}
			$format = explode(">",$ligne);
			if ($format[0] == "compteur")
			{
				$format[1] = trim($format[1]);
				$format[1]++;
				$format = implode (">",$format);
			}
		}
	@fclose($fh);
	@$fh = fopen("$name_temp", "r+");
		while (@!feof($fh))
		{
	@		$ligne2 = fgets($fh);
			if ($ligne2==""){continue;}
			$format2 = explode(">",$ligne2);
			if ($format2[0] == "Description")
			{@fwrite ($fh,$format);}
		}
	@fclose($fh);
}
?>
Si vous avez besoin de plus d'information pour me répondre n'hèsitez pas à me les demander

d'avance merci

Spols