ok. I did that. and i understand your explanation.
But how do i tell the browser that it should download the file??
here is my code that created the file on the server.
function exportToFile($headers,$rows,$name){
$post = date("YmdHis");
$filename = '../report_Files/' . $name . '-' . $post . '.csv';
$fp = fopen($filename, 'w');
fputcsv($fp, $headers);
foreach($rows as $lines) {
fputcsv($fp, $lines);
}
fclose($fp);
return $filename;
}
Then i implemented what you told me. I am using this as the href
filedownloader.php?writefile=yes&type=obu
include_once '../../lib/database.php';
include_once 'report-querys.php';
if(isset($_GET['writefile']) && $_GET['writefile'] == 'yes')
{
if($_GET['type'] == 'obu'){
orderByuser('file'); //the above file function is used within this function when the call for 'file' is requested.
}
}
All i get is a blank page. However, the file has been generated on the server. How do i download it??
Thanks