Forum Moderators: coopster

Message Too Old, No Replies

Create temp file, and download

         

wesg

2:35 am on Aug 12, 2009 (gmt 0)

10+ Year Member



I'm trying to create a component of my page where I put the contents of a variable into a file, then download that file. I've looked at temporary files, but that doesn't make much sense to me.

Any suggestions?

bkeep

2:58 am on Aug 12, 2009 (gmt 0)

10+ Year Member



What type of file are you wanting to create .doc .csv .txt ?

wesg

2:23 am on Aug 14, 2009 (gmt 0)

10+ Year Member



A csv file. The content of the CSV file is saved to a regular variable.

bkeep

2:46 am on Aug 14, 2009 (gmt 0)

10+ Year Member



If you already can dump to the screen in the format you want just add something like this to the end of the page.


$file_out = $your_var;

$out = strlen($file_out);
if (isset($file_out)) {
header("Content-Length: $out");
header("Content-type: application/csv");
header("Content-Disposition: attachment; filename=$filename");
echo $file_out;
exit;
}