Output file without saving

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View

I've seen a few sites that offer this, but I'm not sure how they do it.
It's a form button, that when pressed, prompts the use to download a
file. Like if I want my banking records, I select a date range and
press the button, and it compiles and sends me an excel doc right then.

What I'd like is to comile and deliver a file in that manner, without
saving the file to some directory and providing a link. Does anyone
know how this is done?


Re: Output file without saving

AaronV wrote:
Quoted text here. Click to load it

You send headers that tell the browser to expect something other than
the normal fare, then stream your dynamic content after. e.g:

$csv = '"name","age"' . "\n";
$csv .= '"John Doe", 30' . "\n";
header("Content-type: application/vnd.ms-excel");
header("Content-disposition: attachment; filename=simple.csv");
echo $csv;

Re: Output file without saving

On 6 May 2005 15:56:50 -0700, AaronV wrote:
Quoted text here. Click to load it

See http://php.net/header

Firefox Web Browser - Rediscover the web - http://getffox.com /
Thunderbird E-mail and Newsgroups - http://gettbird.com /

Site Timeline