Force download of dynamically created content.
I want to make a site that enables people to download xml files by pressing on a link to them, but at the moment the xml files just open in a browser window.
I have been trying to do this via php and here is the code I have so far but I can't seem to get it to work. Are there any php gurus out there that can tell me where I am going wrong with it
PHP Code:
// load content into var
$filecontent = $row_rs_xmlfile['xmlcontent'];
//name the file
$downloadfile = $row_rs_xmlfile['xmlurl'];
header("Pragma: public");
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Cache-Control: private",false);
header('Content-Description: File Transfer');
header("Content-Type: application/force-download");
header("Content-disposition: attachment; filename=$downloadfile");
header("Content-Transfer-Encoding: Binary");
header("Content-Length: ".strlen($filecontent));
header("Pragma: no-cache");
header("Expires: 0");
exit();
Ta
|