RE: [PHP-ES] Download de archivos
| From: | Antonio Pérez | Date: | Thu, 01 Jul 2004 08:40:14 +0000 |
| Subject: | RE: [PHP-ES] Download de archivos | ||
| References: | 1 | Groups: | php.general.es |
| Request: | Send a blank email to general-es+get-49734@lists.php.net to get a copy of this message | ||
> <?php
> $file = "docs/";
> $file .= $_GET['fitxer'];
> //$file = "docs/mapa-bcn.pdf"; // file to be send to the
> client $speed = 22.0; // 8,5 kb/s download rate limit
> if(file_exists($file) && is_file($file)) {
> header("Cache-control: private");
> header("Content-Type: application/octet-stream");
> header("Content-Length: ".filesize($file));
> // header("Content-Disposition: filename=$file" . "%20");
> header("Content-Disposition: filename=$file");
La última línea esta debe ser algo así:
header("Content-Disposition: attachment;
filename=\"".basename($file)."\";");
Porque a parte de que te faltaba el attachment, le estabas $file
contiene también el nombre del directorio donde está el fichero.