|
|
|
|
Salut,
Depuis je ne sais comben de jours je suis a la recherche de cette astuce....
Je ne sais pas si vous seriez capable de me répondre mais, j'aimerais inclure du php dans ma page de téléchargement, au lieu d'avoir une adresse tel que http://monsite/v6/mp3/titredumix.zip d'avoir une adresse tel que http://monsite/v6/download.php?id=123
Est-ce possible ???
j'aimerais avoir le code complet recopier s'il y a erreur dans le mien
Le code a mettre dans download.php
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html; charset=ISO-8859-1" http-equiv="content-type">
<title>Télécharger</title>
</head>
<body>
<br>
<?php
$id = $_GET['id'];
if ($id= '1')
{
$file = '/mp3/Dj%20dodo%20-%20Turn%20Me%20Up%20%21.zip';
};
elseif etc avec ts les autres fichiers...
header('Content-Transfer-Encoding: none');
header('Content-Type: application/octetstream; name="'.$file.'"');
header('Content-Disposition: attachment; filename="'.$file.'"');
</body>
</html>
<a href="/download.php?id=1">Télécharger</a>
Parse error: syntax error, unexpected T_ELSEIF in /home/web573/web/v6/html/download.php on line 23
Et d'ailleurs il faut aussi enlever un point-virgule, ajouter les accolades et la fermeture de balise PHP.
<?php
$id = $_GET['id'];
if ($id= '1')
{
$file = '/mp3/Dj%20dodo%20-%20Turn%20Me%20Up%20%21.zip';
}
elseif
{
header('Content-Transfer-Encoding: none');
header('Content-Type: application/octetstream; name="'.$file.'"');
header('Content-Disposition: attachment; filename="'.$file.'"');
}
?>
</body>
[ Mathieu ] « On embauchera plus s'il est moins compliqué de licencier. » LP, 29 août 2007. |
Bonsoir,
switch ($id){
case '1':
$file = '/mp3/Dj%20dodo%20-%20Turn%20Me%20Up%20%21.zip';
break;
case '2':
$file = '/mp3/..................................zip';
break;
case '3':
$file = '/mp3/..............................zip';
break;
//etc.....
}
|
Ok cela fonctionne mais il y a encore une erreur,
|
ça ne fonctionne pas encore....
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html; charset=ISO-8859-1" http-equiv="content-type">
<title>Télécharger</title>
</head>
<body>
<br>
<?php
$id = $_GET['id'];
switch ($id){
case '1':
$file = '/Dj%20dodo%20-%20Turn%20Me%20Up%20%21.zip';
break;
case '2':
$file = '/Dj%20dodo%20-%20Turn%20Me%20Up%20%21.zip';
break;
case '3':
$file = '/Dj%20dodo%20-%20Turn%20Me%20Up%20%21.zip';
break;
header('Content-Transfer-Encoding: none');
header('Content-Type: application/octetstream; name="'.$file.'"');
header('Content-Disposition: attachment; filename="'.$file.'"');
header("Location:".$file);
}
?>
</body>
</html>
|
J'ai essayer Mais ça ne fonctionne pas encore !
<?php
$id = $_GET['id'];
switch ($id){
case '1':
$file = '/Dj%20dodo%20-%20Turn%20Me%20Up%20%21.zip';
break;
case '2':
$file = '/Dj%20dodo%20-%20Turn%20Me%20Up%20%21.zip';
break;
case '3':
$file = '/Dj%20dodo%20-%20Turn%20Me%20Up%20%21.zip';
break;
header('Content-Transfer-Encoding: none');
header('Content-Type: application/octetstream; name="'.$file.'"');
header('Content-Disposition: attachment; filename="'.$file.'"');
header("Location:".$file);
}
?>
|
Oui... ils sont dans le meme répertoire !!!
|
<?php
|