File download question
am 06.09.2009 20:19:59 von chris_payne
Hi Everyone,
I've setup a filedownload which works but i'm having an issue, i've
left out but when it downloads it, while it has the correct file it
doesn't have a file extension associated with it, I need the .7z
extension associated with the filename, can anyone see why that would
do this below?
I'm sure it's something obvious but i'm new to doing file downloads.
Thank you everyone
Chris
$file = "SOMEFILE.7Z";
$speed = 60; // i.e. 60 kb/s download rate
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");
flush();
$fd = fopen($file, "r");
while(!feof($fd)) {
echo fread($fd, round($speed*1024)); // $speed kb at a time
flush();
sleep(1);
}
fclose ($fd);
}
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Re: File download question
am 06.09.2009 20:43:27 von Jonathan Tapicer
I think that your problem in this line:
header("Content-Disposition: filename=3D$file" . "%20");
I don't know what that %20 is for and you should quote the filename,
that line should be something like this:
header("Content-Disposition: attachment; filename=3D\"$file\"");
Considering that $filename already has the 7z extension.
Jonathan
On Sun, Sep 6, 2009 at 3:19 PM, Chris Payne wr=
ote:
> Hi Everyone,
>
> I've setup a filedownload which works but i'm having an issue, i've
> left out but when it downloads it, while it has the correct file it
> doesn't have a file extension associated with it, I need the .7z
> extension associated with the filename, can anyone see why that would
> do this below?
>
> I'm sure it's something obvious but i'm new to doing file downloads.
>
> Thank you everyone
>
> Chris
>
> $file =3D "SOMEFILE.7Z";
> $speed =3D 60; // i.e. 60 kb/s download rate
> if(file_exists($file) && is_file($file)) {
> =A0 header("Cache-control: private");
> =A0 header("Content-Type: application/octet-stream");
> =A0 header("Content-Length: ".filesize($file));
> =A0 header("Content-Disposition: filename=3D$file" . "%20");
> =A0 flush();
> =A0 $fd =3D fopen($file, "r");
> =A0 while(!feof($fd)) {
> =A0 =A0 =A0echo fread($fd, round($speed*1024)); // $speed kb at a time
> =A0 =A0 =A0flush();
> =A0 =A0 =A0sleep(1);
> =A0 }
> =A0 fclose ($fd);
> }
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
RE: File download question
am 06.09.2009 22:18:02 von Andrea Giammarchi
--_808856bf-6c56-4ef7-8350-a8206881b31a_
Content-Type: text/plain; charset="Windows-1252"
Content-Transfer-Encoding: quoted-printable
That is for IE and its silly FileName[N] rather than FileName
here a good old function to download:
http://www.devpro.it/code/72.html
Regards
> Date: Sun=2C 6 Sep 2009 15:43:27 -0300
> From: tapicer@gmail.com
> To: chris_payne@danmangames.com
> CC: php-general@lists.php.net
> Subject: Re: [PHP] File download question
>=20
> I think that your problem in this line:
>=20
> header("Content-Disposition: filename=3D$file" . "%20")=3B
>=20
> I don't know what that %20 is for and you should quote the filename=2C
> that line should be something like this:
>=20
> header("Content-Disposition: attachment=3B filename=3D\"$file\"")=3B
>=20
> Considering that $filename already has the 7z extension.
>=20
> Jonathan
>=20
>=20
> On Sun=2C Sep 6=2C 2009 at 3:19 PM=2C Chris Payne
..com> wrote:
> > Hi Everyone=2C
> >
> > I've setup a filedownload which works but i'm having an issue=2C i've
> > left out but when it downloads it=2C while it has the correct file it
> > doesn't have a file extension associated with it=2C I need the .7z
> > extension associated with the filename=2C can anyone see why that would
> > do this below?
> >
> > I'm sure it's something obvious but i'm new to doing file downloads.
> >
> > Thank you everyone
> >
> > Chris
> >
> > $file =3D "SOMEFILE.7Z"=3B
> > $speed =3D 60=3B // i.e. 60 kb/s download rate
> > if(file_exists($file) && is_file($file)) {
> > header("Cache-control: private")=3B
> > header("Content-Type: application/octet-stream")=3B
> > header("Content-Length: ".filesize($file))=3B
> > header("Content-Disposition: filename=3D$file" . "%20")=3B
> > flush()=3B
> > $fd =3D fopen($file=2C "r")=3B
> > while(!feof($fd)) {
> > echo fread($fd=2C round($speed*1024))=3B // $speed kb at a time
> > flush()=3B
> > sleep(1)=3B
> > }
> > fclose ($fd)=3B
> > }
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe=2C visit: http://www.php.net/unsub.php
> >
> >
>=20
> --=20
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe=2C visit: http://www.php.net/unsub.php
>=20
____________________________________________________________ _____
More than messages=96check out the rest of the Windows Live=99.
http://www.microsoft.com/windows/windowslive/=
--_808856bf-6c56-4ef7-8350-a8206881b31a_--