Mark Lo wrote:
>
> Hi,
>
> Is there any php download function for php. I am asking is the one like
> downloading the file from the server when people click the link. Like
> downloading php sources tar file.
>
> Thank you
>
> Mark
No download function that I know of, but it isn't hard to
download.
The trick is to send out a Content-Type header with the
Mime type,
an optional Content-disposition to suggest a name and then
whatever it is you want
to download.
e.g. to download some data in tab-delimited format -
header("Content-type: text/tab-separated-values");
header("Content-disposition: inline;
filename=".$myfilename);
while(...
{
print "\t$field1\t$field2\t$field3\t$field4\n";
}
exit;
You can download any mime type, so it could just as well be
downloading a
text file, a word-processor document, an image, a Shockwave
file or whatever.
You can easily use readfile to pick up the contents of an
existing file.
If you find the browser is trying to get too clever when it
spots the Mime type,
you can always make up your own, which should force it to
just offer a save.
Hope that helps.
George
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]