下面那种寫法也可以了
if($fname && fpath)
{
header("Content-length: " . filesize($fpath));
header("Content-type: application/octet-stream");
header("Content-Disposition: attachment\; filename=$fname");
header("Content-Description: PHP Generated Data");
header("Content-Transfer-Encoding: binary");
readfile($fpath);
}
if($fname && fpath)
{
header("Content-length: " . filesize($fpath));
header("Content-type: application/octet-stream");
header("Content-Disposition: attachment\; filename=$fname");
header("Content-Description: PHP Generated Data");
header("Content-Transfer-Encoding: binary");
readfile($fpath);
}
这样可以避免用户直接用超连接进行下栽下栽的时候,先登录,然后用fopen读文件,输出相应的文件头,
即可完成下栽
如果先输出文件头,再用php函数读取文件,显然要影响效率,安全和效率向来都有点矛盾的
放到虚拟路经下,并不安全,不好。
fopen读字节流是慢
干脆,直接列出目录好了,每个目录下一个dir.txt说明文件
弄得跟ftp似得,算了
干脆开个ftp得了,省事