欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

解析PHP實現(xiàn)下載文件的兩種方法

 更新時間:2013年07月05日 08:49:35   作者:  
本篇文章是對使用PHP實現(xiàn)下載文件的兩種方法進行了詳細的分析介紹,需要的朋友參考下
方法一:
復制代碼 代碼如下:

 header('Content-Description: File Transfer');
 header('Content-Type: application/octet-stream');
 header('Content-Disposition: attachment; filename='.basename($filepath));
 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($filepath));
 readfile($file_path);

方法二:
復制代碼 代碼如下:

 $fileinfo = pathinfo($filename);
 header('Content-type: application/x-'.$fileinfo['extension']);
 header('Content-Disposition: attachment; filename='.$fileinfo['basename']);
 header('Content-Length: '.filesize($filename));
 readfile($thefile);
 exit();

相關(guān)文章

最新評論