RE: [PHP] Download Script
| From: | Ivo Pletikosic | Date: | Fri, 27 Aug 2004 18:50:48 +0000 |
| Subject: | RE: [PHP] Download Script | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-194955@lists.php.net to get a copy of this message | ||
> I am
> wondering if this is my headers that are doing this, but I
> really dont know.
I think its an IE or Windows behavior and what causes it is the multiple
dots in the filename. I resorted to naming our downloads
"filename-v1_0_2_1.exe"
> -----Original Message-----
> From: Aaron Todd [mailto:aaloki88@hotmail.com]
> Sent: Friday, August 27, 2004 11:35 AM
> To: php-general@lists.php.net
> Subject: [PHP] Download Script
>
>
> I've created a download script that works quite nicely. The
> only issue with
> it is that when I download a file where the file name is like
> "filename
> v1.0.2.1.exe" there is some extra characters added into the
> name when it is
> downloaded. So that file will be "filename v1[1].0.2.1.exe". I am
> wondering if this is my headers that are doing this, but I
> really dont know.
>
> Here is my code:
> <?php
> $file = $_GET['file'];
> $path = $_GET['type'];
> $rootpath = "/home/virtual/site341/fst/var/www/downloads/";
> $filename = "$rootpath$path/$file";
> if (file_exists($filename)) {
> header("Content-Description: File Transfer");
> header("Pragma: no-cache");
> header("Content-Type: application/force-download");
> header("Content-Disposition: attachment;
> filename=".basename($filename));
> header("Content-Length: ".filesize($filename));
> $handle = fopen(($filename), "r");
> print(fread($handle, filesize($filename)));
> flush();
> fclose($handle);
> } else {
> header("HTTP/1.0 404 Not Found");
> }
> ?>
> If anyone can let me know what is going on I'd appreciate it.
>
> Thanks,
>
> Aaron
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>