Hello,
I have written a web page that creates a file (by calling a js function that does an ajax call to create a file) and also then creates a button to download the file (again by calling a js function that does an ajax call).
the text file is created successfully and the download nearly works - it finds the correct file but echos it to screen instead of forcing a download.
I've looked at dozens of examples of how to set up the headers to make the file download but the readfile just directs straight to the screen. The php that's called to download the file is as follows:
<?php
$database = 'cut';
include '../../../../cut/libraries/ashby/mainconfig.php';
$path="../../../../cut/components/com_quickbooks/output/";
//$path="../output/";
$filename = mysql_real_escape_string( $_GET['filename'] );
header('Pragma: public');
header('Content-Length: ' . filesize($path.$filename));
header('Expires: 0');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename='.$path.$filename);
header("Content-Transfer-Encoding: binary");
header('Content-Description: File Transfer');
readfile($path.$filename);
?>
I'd really appreciate a fresh pair of eyes
Thanks