Re: Dump file to local computer
| From: | Alex Shi | Date: | Mon, 12 May 2003 19:22:45 +0000 |
| Subject: | Re: Dump file to local computer | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-147340@lists.php.net to get a copy of this message | ||
Thank you very much for your instant help!
Actually I am doing research and your reply is a great guidelines
to my research :))
cheers
Alex
----- Original Message -----
From: "Mike" <php-digest@custom87.net>
To: "Alex Shi" <chpshi@eol.ca>
Sent: Monday, May 12, 2003 3:14 PM
Subject: Re: [PHP] Dump file to local computer
> This one time, over a cup of hot coffee, Alex Shi said:
> > Hi,
> >
> > How to use php to handle downloading a file or content in a buffer into
> > local computer as a file?
> >
> > Alex
>
> So I'll answer your question even though some people may think you
> didn't research (*cough* Kevin Stone *cough*)...
>
> So you want a script:
>
> <?php
>
> //first send the correct headers
> header ("Content-type: application/octet-stream");
> header ("Content-Disposition: attachment; filename=" . $filename);
> //optionally, you can do a :
> header ("Pragma: no-cache");
> //so they can't cache the downloaded file in the browser
>
> //then give them the file... you might first want to check if
> //the file exists.
> readfile ($filename);
>
> ?>
>
>
>