Probleme de téléchargement
Résolu
-----coco-----
Messages postés
87
Date d'inscription
Statut
Membre
Dernière intervention
-
-----coco----- Messages postés 87 Date d'inscription Statut Membre Dernière intervention -
-----coco----- Messages postés 87 Date d'inscription Statut Membre Dernière intervention -
Bonjour,
j'ai un probleme...je voudrais pouvoir télécharger un fichier qui est sur le serveur donc :
$file_path = 'dos/'.$titre;
$ofile = fopen ($file_path, 'r');
$tt = str_replace('.', '/', $titre);
header('Content-Type: $tt');
header("Content-Disposition: attachment; filename=$titre");
$content = readfile($file_path);
echo $content;
fclose ($ofile);
... $titre = 'a.doc' par exemple
donc tous ce passe bien, mais fichier que je télécharge sont corrompus...quand je les ouvre en .txt, j'obtiens un melange du code de ma page web et du fichier que j'ai recu...
j'avoue que c'est assez bizard...si quelqu'un sait ??
merci d'avance...
j'ai un probleme...je voudrais pouvoir télécharger un fichier qui est sur le serveur donc :
$file_path = 'dos/'.$titre;
$ofile = fopen ($file_path, 'r');
$tt = str_replace('.', '/', $titre);
header('Content-Type: $tt');
header("Content-Disposition: attachment; filename=$titre");
$content = readfile($file_path);
echo $content;
fclose ($ofile);
... $titre = 'a.doc' par exemple
donc tous ce passe bien, mais fichier que je télécharge sont corrompus...quand je les ouvre en .txt, j'obtiens un melange du code de ma page web et du fichier que j'ai recu...
j'avoue que c'est assez bizard...si quelqu'un sait ??
merci d'avance...
A voir également:
- Probleme de téléchargement
- Site de telechargement - Accueil - Outils
- Dark world telechargement - Guide
- Téléchargement - Télécharger - Compression & Décompression
- Telechargement - Télécharger - Traitement de texte
- Adobe Reader - Télécharger - PDF
7 réponses
-----coco-----
Messages postés
87
Date d'inscription
Statut
Membre
Dernière intervention
25
j'essai...
Bonjour,
cela me semble normal. Un fichier .doc s'ouvre avec word, un fichier .txt avec un éditeur de texte (blocnote).
un document word est un fichier formaté avec des codes de mises en page.
cela me semble normal. Un fichier .doc s'ouvre avec word, un fichier .txt avec un éditeur de texte (blocnote).
un document word est un fichier formaté avec des codes de mises en page.
bonjour et merci...
mais non ce n'est pas normal, car ce que l'on voit avec l'editeur de texte, c'est ma page web, elle s'appelle recevoir.php donc elle commence par :
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr" lang="fr">
<head>
<title>Reception</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<link rel="stylesheet" media="screen" type="text/css" title="Design" href="CSS.css" />
</head>
<body>
...je ne met pas la fin...c'est rop long
et donc, sur le fichier télécharger, ca comme par la meme chose...
mais non ce n'est pas normal, car ce que l'on voit avec l'editeur de texte, c'est ma page web, elle s'appelle recevoir.php donc elle commence par :
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr" lang="fr">
<head>
<title>Reception</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<link rel="stylesheet" media="screen" type="text/css" title="Design" href="CSS.css" />
</head>
<body>
...je ne met pas la fin...c'est rop long
et donc, sur le fichier télécharger, ca comme par la meme chose...
désolé ce n'est pas ce qui est noté dans le premier post. il est noté ... $titre = 'a.doc' par exemple
d'où ma réponse.
d'où ma réponse.
oui et donc ma réponse est correcte, le bloic note affiche du texte et pas du binaire.
sans télécharger un fichier ouvrez un www;jpg avec le bloc note et vous ne verrez que des caractères illisibles.
sans télécharger un fichier ouvrez un www;jpg avec le bloc note et vous ne verrez que des caractères illisibles.
par exemple, avant je met sur mon serveur un fichier texte qui contient :
ceci est le texte du fichier a.txt
apres je le telecharge et j'ai :
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr" lang="fr">
<head>
<title>Reception</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<link rel="stylesheet" media="screen" type="text/css" title="Design" href="CSS.css" />
</head>
<body>
<img src="ban.jpg" alt="banniere" />
<br /><br /><br /><br />
<div id="menu">
<div class="elm">
<a href="forme.php">ICI,<br />on envoie<br /><br /></a>
<a href="/formr.php">ICI,<br />on recoit</a>
<a href="../index.php">ICI,<br />sommaire</a>
</div>
</div>
<div id="corps">
ceci est le texte du fichier a.txt
</div>
</body>
</html>
ce qui est le debut et la fin de ma page web...
ceci est le texte du fichier a.txt
apres je le telecharge et j'ai :
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr" lang="fr">
<head>
<title>Reception</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<link rel="stylesheet" media="screen" type="text/css" title="Design" href="CSS.css" />
</head>
<body>
<img src="ban.jpg" alt="banniere" />
<br /><br /><br /><br />
<div id="menu">
<div class="elm">
<a href="forme.php">ICI,<br />on envoie<br /><br /></a>
<a href="/formr.php">ICI,<br />on recoit</a>
<a href="../index.php">ICI,<br />sommaire</a>
</div>
</div>
<div id="corps">
ceci est le texte du fichier a.txt
</div>
</body>
</html>
ce qui est le debut et la fin de ma page web...
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre question
???? c'est quoi le nombre de ligne ?
je reagrde de plus près.
en attendant regardez là
https://php.developpez.com/faq/?page=fichiers#fichiers_forcedownload
ou alors
<?
$file=$_GET['file'];
//telechargement
$taille=filesize("doc/$file");
header("Content-Type: application/force-download; name=\"$file\"");
header("Content-Transfer-Encoding: binary");
header("Content-Length: $taille");
header("Content-Disposition: attachment; filename=\"$file\"");
header("Expires: 0");
header("Cache-Control: no-cache, must-revalidate");
header("Pragma: no-cache");
readfile("doc/$file");
exit();
?>
je reagrde de plus près.
en attendant regardez là
https://php.developpez.com/faq/?page=fichiers#fichiers_forcedownload
ou alors
<?
$file=$_GET['file'];
//telechargement
$taille=filesize("doc/$file");
header("Content-Type: application/force-download; name=\"$file\"");
header("Content-Transfer-Encoding: binary");
header("Content-Length: $taille");
header("Content-Disposition: attachment; filename=\"$file\"");
header("Expires: 0");
header("Cache-Control: no-cache, must-revalidate");
header("Pragma: no-cache");
readfile("doc/$file");
exit();
?>