function stats_download_csv_from_batch_file
Search API
| 7.x stats.module | stats_download_csv_from_batch_file($batch_id) |
Lets the user download a CSV file from a completed batch, from a file created during the batch operation.
Parameters
unknown_type $batch_id:
File
- modules/
stats/ stats.module, line 262 - This module displays statistics and reports for FlightPath
Code
function stats_download_csv_from_batch_file($batch_id) {
$filename = fp_get_machine_readable(strtolower($_REQUEST ["filename"]));
$batch = batch_get($batch_id);
watchdog('stats', "download_csv_from_batch_file batch_id:$batch_id, filename:$filename.csv", array());
// calcuate the full path to the file...
$private_path = fp_get_files_path() . "/private";
$batch_id = $batch ['batch_id'];
$created = $batch ['created'];
$filepath = $private_path . '/batch_' . $batch_id . '__' . $created . '.csv.tmp';
// Give it to the browser...
header('Content-type: text/csv');
header('Content-Disposition: attachment; filename="' . $filename . '.csv"');
// Read directly from the server...
readfile($filepath);
die;
}
