$contenttype = get_post_mime_type( $file[ 'id' ] );
$filename = basename( $file[ 'url' ] );
set_time_limit( 0 );
header( "Content-Disposition: attachment; filename=\"{$filename}\"" );
header("Content-Type: application/x-force-download; name=\"{$filename}\"");
header( 'Expires: 0' );
header( 'Cache-Control: must-revalidate' );
header( 'Pragma: public' );
header( 'Content-Length: ' . filesize($file_dir) );
readfile( $file_dir );
exit;
if (ob_get_length()) ob_end_clean();
header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename="' . basename($file->display_name) . '"');
header('Content-Transfer-Encoding: binary');
header('Connection: Keep-Alive');
header('Expires: 0');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Pragma: public');
header('Content-Length: ' . filesize($file->path));
if ($fd = fopen($file->path, 'rb')) {
while (!feof($fd)) {
print fread($fd, 1024);
}
fclose($fd);
}
exit;