php原生怎麼下載?
1.整個網頁的html介面原始碼下載:
xiazai.php
<html> <head> <meta charset ="utf-8"> <title></title> </head> <body> <form method="post" action="xiazai.php"> <input type="submit" name="xz" id="xz" value="下載" /> </form> </body> </html> <?php //檔案下載 //readfile $filename ="xiazia.php"; if(!empty($_POST["xz"])){ $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(); } ?>
顯示結果為:點選下載按鈕,下載整個頁面:
更多的PHP相關知識,請存取PHP中文網!
以上就是php原生怎麼下載的詳細內容,更多請關注TW511.COM其它相關文章!