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原生怎麼下載的詳細內容。更多資訊請關注PHP中文網其他相關文章!