Re: download script
| From: | Aaron Todd | Date: | Wed, 11 Aug 2004 18:45:44 +0000 |
| Subject: | Re: download script | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-193354@lists.php.net to get a copy of this message | ||
Thanks for your reply,
I am not getting an error at all. I have coded some error traping so if the
files is not found it will tell you instead of displaying an error. As a
test I took all of that out so the script was:
$file = "/home/dlr/test/".$_GET['file'].""
header("Content-Description: File Transfer");
header("Content-Type: application/force-download");
header("Content-Disposition: attachment; filename=".basename($file));
readfile($file);
I also took out the @ as you suggested.
Like that it brings up a download window like it should and then downloads a
file with the correct name, but it is only about 400 bytes and cannot be
read.
Thanks again for your help,
Aaron
"John Nichel" <john@kegworks.com> wrote in message
news:41190F92.6000500@kegworks.com...
> Aaron Todd wrote:
> <snip>
> > <?php
> > $file = "/home/dlr/test/".$_GET['file']."";
> > if (file_exists(basename($file))) {
> > header("Content-Description: File Transfer");
> > header("Content-Type: application/force-download");
> > header("Content-Disposition: attachment; filename=".basename($file));
> > @readfile($file);
> > } else {
> > echo "$file<br>";
> > echo basename($file);
> > echo "<br>No File Found";
> > }
> > ?>
>
> Belay my last post...you're using readfile and not fread.
>
> Okay, what error is the script outputting? You should remove the '@'
> from in front of readfile() so that it will output an error if it's the
> problem.
>
> --
> John C. Nichel
> ÜberGeek
> KegWorks.com
> 716.856.9675
> john@kegworks.com