Précédent   Forum des professionnels en informatique > PHP > Langage
Langage Forum sur le langage PHP, la POO, les conventions, la sécurité, etc. Avant de poster : FAQ Langage, toutes les FAQ PHP, cours langage et sources PHP
Partagez cette discussion sur d'autres réseaux sociaux : Viadeo Twitter Google Facebook Digg Delicious MySpace Yahoo
Réponse Proposer ce sujet en actualité
 
Outils de la discussion
Publicité
'
Vieux 21/06/2008, 15h18   #1
Invité de passage
 
Inscription : juin 2008
Messages : 3
Détails du profil
Informations forums :
Inscription : juin 2008
Messages : 3
Points : 1
Points : 1
Par défaut Page de téléchargement

Bonjour,

je suis en train de faire un site d'échange de fichier et je suis actuellement sur ma page de download.

Voici le script :
Code :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
 
<?php
session_start();
 
if(isset($_GET['id']) && isset($_SESSION['identification']) && $_SESSION['struct']==1)
{
 
	$db=mysql_connect("localhost","root","");
    mysql_select_db("stage",$db);
	$sql = "select * from docs where id='".$_GET['id']."';";
    $req=mysql_query($sql) or die('Erreur SQL !<br>'.$sql.'<br>'.mysql_error());	
	$res=mysql_fetch_array($req);
	$fichier = $res['chemin'].$res['nom'];
 
	echo $fichier;
 
    header("Content-type: application/force-download");
    header("Content-Length: ".$res['taille']);
    header("Content-Disposition: attachment; filename=".$fichier);
    readfile($fichier);
 
mysql_close();
}
elseif(!isset($_GET['id']) ) echo 'Merci de laisser l\'id transmise par l\'url ';
elseif(isset($_SESSION['identification']) && $_SESSION['struct']!=1) echo 'Téléchargement interdit';
elseif(!isset($_SESSION['identification'])) echo 'Accès interdit';
?>
Le problèe est que dès que je veux télécharger un fichier, voila ce qui est affiché :

Warning: Cannot modify header information - headers already sent by (output started at c:\documents and settings\pross\bureau\stage\site d'echange\download.php:14) in c:\documents and settings\pross\bureau\stage\site d'echange\download.php on line 16

Warning: Cannot modify header information - headers already sent by (output started at c:\documents and settings\pross\bureau\stage\site d'echange\download.php:14) in c:\documents and settings\pross\bureau\stage\site d'echange\download.php on line 17

Warning: Cannot modify header information - headers already sent by (output started at c:\documents and settings\pross\bureau\stage\site d'echange\download.php:14) in c:\documents and settings\pross\bureau\stage\site d'echange\download.php on line 18

puis une longue suite de caractère bizarre (ca m'a l'air d'être du langage machine.

Si quelqu'un avais une petite idée du pourquoi de cette erreur, je suis preneur.

Merci de vos réponses
the_ourson est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 21/06/2008, 15h43   #2
Modérateur
 
Avatar de sabotage
 
Homme Vincent
Inscription : juillet 2005
Messages : 14 929
Détails du profil
Informations personnelles :
Nom : Homme Vincent

Informations forums :
Inscription : juillet 2005
Messages : 14 929
Points : 16 383
Points : 16 383
Citation:
Warning: Cannot modify header information - headers already sent
Tu ne peux pas ecrire du texte (echo $fichier) avant l'envoi des headers HTML.

Citation:
puis une longue suite de caractère bizarre (ca m'a l'air d'être du langage machine.
Ca c'est le resultat normal de ton readfile()
sabotage est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 21/06/2008, 16h21   #3
Invité de passage
 
Inscription : juin 2008
Messages : 3
Détails du profil
Informations forums :
Inscription : juin 2008
Messages : 3
Points : 1
Points : 1
tout simplement, j'y avais pas pensé.

merci bcp ca marche mieux maintenant.

dslé pour cette question bête, mais je débute
the_ourson est déconnecté   Envoyer un message privé Réponse avec citation 00
Réponse Proposer ce sujet en actualité Cette discussion est résolue.
Outils de la discussion



Fuseau horaire GMT +2. Il est actuellement 03h04.


 
 
 
 
Partenaires

Hébergement Web