Home > Article > Backend Development > How to download php native
How to download php natively?
1. Download the html interface source code of the entire web page:
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(); } ?>
The displayed result is: click the download button to download the entire page:
For more PHP related knowledge, please visit PHP Chinese website!
The above is the detailed content of How to download php native. For more information, please follow other related articles on the PHP Chinese website!