1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
|
//Force download
function _force_file_download($filepath, $filename) {
//Disable GZIP compression
if (ini_get("zlib.output_compression")) {
ini_set("zlib.output_compression", "Off");
}
session_write_close();
$path = $filepath.'/'.$filename;
$ifp = fopen( $path, "rb" );
$fileData = fread( $ifp, filesize($path) );
fclose( $ifp );
//file_transfer($filepath, $headers);
header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename=\"'.urldecode($filename).'\"');
header('Content-Transfer-Encoding: binary');
header('Expires: 0');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Pragma: public');
header('Content-Length: ' . filesize($path));
flush();
echo $fileData;
unlink($path);
drupal_exit();
} |
Partager