Mammouth du PHP |
620 Messages
22 mai 2010, 10:02
oui merci je sais que sa se fait avec le header mais je ne sais pas comment transformé ma ligne de code actuel en consequence.
actuellement j'essai de faire celà :
dans ma page ou j'ai mes liens pdf je met :
<a href="download-doc.php?file=../cartes/carte-des-Vins.pdf">telecharger </a>
ensuite j'ai créé un page php download-doc.php
<?php
$file=$_GET['file'];
//telechargement
$taille=filesize("../carte/$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("../carte/$file");
exit();
?>
mais sa ne fonctionne pas j'ai un ta d'erreurs du genre :
Warning: filesize() [function.filesize]: stat failed for ../carte/carte-des-Vins.pdf in /var/www/monsite.com/download-doc.php on line 5
Warning: Cannot modify header information - headers already sent by (output started at /var/www/monsite.com/download-doc.php:5) in /var/www/monsite.com/download-doc.php on line 6
Warning: Cannot modify header information - headers already sent by (output started at /var/www/monsite.com/download-doc.php:5) in /var/www/monsite.com/download-doc.php on line 7
Warning: Cannot modify header information - headers already sent by (output started at /var/www/monsite.com/download-doc.php:5) in /var/www/monsite.com/download-doc.php on line 8
Warning: Cannot modify header information - headers already sent by (output started at /var/www/monsite.com/download-doc.php:5) in /var/www/monsite.com/download-doc.php on line 9
Warning: Cannot modify header information - headers already sent by (output started at /var/www/monsite.com/download-doc.php:5) in /var/www/monsite.com/download-doc.php on line 10
Warning: Cannot modify header information - headers already sent by (output started at /var/www/monsite.com/download-doc.php:5) in /var/www/monsite.com/download-doc.php on line 11
Warning: Cannot modify header information - headers already sent by (output started at /var/www/monsite.com/download-doc.php:5) in /var/www/monsite.com/download-doc.php on line 12
Warning: readfile(../carte/carte-des-Vins.pdf) [function.readfile]: failed to open stream: No such file or directory in /var/www/monsite.com/download-doc.php on line 13