Home  >  Article  >  Backend Development  >  How to download php native

How to download php native

藏色散人
藏色散人Original
2019-11-05 09:15:422847browse

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(&#39;Content-type: application/x-&#39;.$fileinfo[&#39;extension&#39;]);
    header(&#39;Content-Disposition: attachment; filename=&#39;.$fileinfo[&#39;basename&#39;]);
    header(&#39;Content-Length: &#39;.filesize($filename));
    readfile($thefile);
    exit();
}
?>

The displayed result is: click the download button to download the entire page:

How to download php native

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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Previous article:What is php source codeNext article:What is php source code