php可以下载exe文件吗

WBOY
Release: 2016-06-23 14:04:37
Original
1793 people have browsed it

php可以下载exe文件吗  像下载rar那样先fread  在输出就下载了,不要通过访问exe文件在网站的路径下载,请问可以实现这个效果吗?


回复讨论(解决方案)

同求,留名
据我所知是不行的


//这里可加你想加的代码,如:
/*
if (!($_SERVER['HTTP_REFERER'] && strpos($_SERVER['HTTP_REFERER'], 'http://'.$_SERVER['HTTP_HOST']) === 0)) {
  die('禁止站外操作!');
}
*/

header('Content-type: application/octet-stream'); //exe文件的mime格式
header('Content-Disposition: attachment; filename=yournewfilename.exe'); //你希望下载为新的文件名
echo file_get_contents('yourfile.exe'); //取文件源,当然这里也可以用fopen、fread读取文件

?>

获取文件的路径,压缩再下载。

关键是header设置正确,否则可能文件数据直接在浏览器里被显示出来。

原理上可行,要看服务端的配置情况。

当然可以。也可以用readfile()方法读取文件

当然可以。也可以用readfile()方法读取文件
我试着用frend读取 在设置hearder后输出  是可以下载exe的但我来源的是90m的exe文件,下载下来的确只有180b的文件,.......

获取文件的路径,压缩再下载。
每次我用php去读取exe文件在设置头信息后输出下载 下载下来的老只有180b的文件,求指导下,着是为什么啊?

关键是header设置正确,否则可能文件数据直接在浏览器里被显示出来。
设置了,好像php读取不了exe文件啊

php脚本设置
set_time_limit(0);
试试?是不是文件太大,超时了?

Related labels:
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 Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!