function _filebrowser_file_download in Filebrowser 6.2
hook_filebrowser_download_manager_process implementation.
1 call to _filebrowser_file_download()
- filebrowser_page_download in includes/
downloads.inc - Callback for filebrowser_download/%node menu.
File
- includes/
downloads.inc, line 96
Code
function _filebrowser_file_download($file, $filename) {
header('Content-Description: File Transfer');
header("Cache-Control: public, must-revalidate, max-age=0");
// HTTP/1.1
header("Pragma: public");
header("Expires: Sat, 26 Jul 1997 05:00:00 GMT");
// Date in the past
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Content-Type: " . file_get_mimetype($filename));
header("Content-Transfer-Encoding: binary");
header("Content-Length: " . filesize($file));
if (eregi("MSIE", getenv("HTTP_USER_AGENT")) || eregi("Internet Explorer", getenv("HTTP_USER_AGENT"))) {
header('Content-Disposition: inline; filename="' . mb_convert_encoding(_filebrowser_safe_basename($filename), "ISO-8859-2", "UTF-8") . '";');
}
else {
header('Content-Disposition: inline; filename="' . _filebrowser_safe_basename($filename) . '";');
}
$block_size = 4096;
$buffer = '';
$handle = fopen($file, 'rb');
set_time_limit(0);
if ($handle !== FALSE) {
while (!feof($handle)) {
$buffer = fgets($handle, $block_size);
echo $buffer;
ob_flush();
flush();
}
fclose($handle);
}
return TRUE;
}