function downloadfile($file){
/*coded by alessio delmonti*/
$file_name = $file;
$mime = 'application/force-download';
header('pragma: public'); // required
header('expires: 0'); // no cache
header('cache-control: must-revalidate, post-check=0, pre-check=0');
header('cache-control: private',false);
header('content-type: '.$mime);
header('content-disposition: attachment; filename='.basename($file_name).'');
header('content-transfer-encoding: binary');
header('connection: close');
readfile($file_name); // push it out
exit();
}
http://www.bkjia.com/phpjc/364768.htmlwww.bkjia.comtruehttp://www.bkjia.com/phpjc/364768.htmltecharticle利用 php 代码强制下载文件的类型,有时需要一些文件不能在线打开,而是执行后需要下载,这时就用这个函数就可以解决了 function downlo...
