Re: Download Script
| From: | Jasper Howard | Date: | Fri, 27 Aug 2004 20:58:09 +0000 |
| Subject: | Re: Download Script | ||
| References: | 1 2 3 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-194963@lists.php.net to get a copy of this message | ||
yeah, but images with filenames something like this -> cool_image
v2.5.443.jpg
--
-------------------------------------------------------------->>
Jasper Howard :: Database Administration
Velocity7
1.530.470.9292
http://www.Velocity7.com/
<<--------------------------------------------------------------
"Aaron Todd" <aaloki88@hotmail.com> wrote in message
news:20040827204544.48196.qmail@pb1.pair.com...
> Were you trying to download any files in the format "filename
v1.0.2.0.exe"
>
> I just tried using readfile and got the same results.
>
> Aaron
>
> "Jasper Howard" <jasper@velocity7.com> wrote in message
> news:20040827191024.52104.qmail@pb1.pair.com...
> > When I created a download script a couple weeks ago I used
> > readfile($filename) instead of fread() and didn't get anything like what
> > you're getting.
> >
> > [snippet]
> > header("Content-type: $type");
> > header('Content-Disposition: attachment;
filename="'.$file_name.'"');
> > readfile($dfile);
> > [/snippet]
> > NOTE: $dfile = path + file;
> >
> > --
> >
> >
> > -------------------------------------------------------------->>
> > Jasper Howard :: Database Administration
> > Velocity7
> > 1.530.470.9292
> > http://www.Velocity7.com/
> > <<--------------------------------------------------------------
> > "Aaron Todd" <aaloki88@hotmail.com> wrote in message
> > news:20040827183521.23415.qmail@pb1.pair.com...
> >> 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