Home > php教程 > php手册 > 写一个php文件,里面放一按钮,点击按钮时找到指定文件下载(该p

写一个php文件,里面放一按钮,点击按钮时找到指定文件下载(该p

WBOY
Release: 2016-06-06 19:41:47
Original
1410 people have browsed it

我写的代码如下: ?php function query(){ $file_name = "info_check.exe"; $file_dir = "www.easycn.net/"; $file = @ fopen($file_dir . $file_name,"r"); if (!$file) { echo "文件找不到"; } else { Header("Content-type: application/octet-stream");

我写的代码如下:

function query(){
$file_name = "info_check.exe";
$file_dir = "www.easycn.net/";
$file = @ fopen($file_dir . $file_name,"r");
if (!$file) {
  echo "文件找不到";
} else {
  Header("Content-type: application/octet-stream");
  Header("Content-Disposition: attachment; filename=" . $file_name);
  while(!feof ($file)) {
echo fread($file,50000);
}
  fclose ($file);
}
}
if($_POST["do"]=="yes"){
query();
}
?>

 

这样写应该不对,不知道怎样才能点击按钮调用php写的方法。。。我想实现的功能是点击按钮下载apk文件

求高受解决一下!不胜感激

source:php.cn
Statement of this Website
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
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template