php下载保存文件保存到本地的两种方法。
第一种:
1 <?php 2 function downfile() 3 { 4 $filename=realpath("resume.html"); //文件名 5 $date=date("Ymd-H:i:m"); 6 Header( "Content-type: application/octet-stream "); 7 Header( "Accept-Ranges: bytes "); 8 Header( "Accept-Length: " .filesize($filename)); 9 header( "Content-Disposition: attachment; filename= {$date}.doc"); 10 echo file_get_contents($filename);11 readfile($filename); 12 }13 downfile();14 ?>