Home > Backend Development > PHP Tutorial > 请问:header上载有关问题

请问:header上载有关问题

WBOY
Release: 2016-06-13 10:46:09
Original
995 people have browsed it

请教:header下载问题
用实现header下载,代码如下,每次点击都是下载空白文件。怎么修改
if(!empty($_GET[fn])){

header('Content-Encoding: none');
header('Content-Type: text/plain');
header('Content-Length: '.filesize( $file_name));
header('Content-Disposition: attachment; filename=".$fn."');

}
还有的就是一个get按钮,我就不发出来了,新人没分。

------解决方案--------------------
if(!empty($_GET[fn])){
$fn=$_GET['fn'];
header('Content-Encoding: none');
header('Content-Type: text/plain');
header('Content-Length: '.filesize( $fn));
header('Content-Disposition: attachment; filename="'.$fn.'"');
readfile($fn);
}
------解决方案--------------------
你只发送了头,却没有发送身体
------解决方案--------------------
缺少readfile('路径/文件名');吧。

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