Send file to browser problem
Posted: Mon Oct 13, 2003 2:01 pm
ok... here is what i want to do.
i run a query on a database. i create a txt file with the query results. now i want that txt file to be sent to the browser, so the person that runs the report can save it to their local drive.
im trying it via headers, and here is what i have so far:
this doesnt quite act the way i want it to... once the file is downloaded, i want the page to refresh... but it doesnt, it just sits there hehe. any ideas?
i run a query on a database. i create a txt file with the query results. now i want that txt file to be sent to the browser, so the person that runs the report can save it to their local drive.
im trying it via headers, and here is what i have so far:
Code: Select all
<?php
$output_file = fopen("tmp_report.txt", "wb");
fwrite($output_file, $output_txt);
fclose($output_file);
$download_size = filesize("tmp_report.txt");
header("Content-type: application/x-download");
header("Content-Disposition: attachment; filename=tmp_report.txt;");
header("Accept-Ranges: bytes");
header("Content-Length: $download_size");
@readfile("tmp_report.txt");
exit;
?>