lighttpd文件下载实现

只需要如下的简单的代码,就可以实现高性能的文件下载,原理很简单..就是linux的”零拷贝”特性..也无非就是sendfile的API的使用问题


header("Content-Disposition:attachment;filename= \"{$filename}\"");
header("X-LIGHTTPD-send-file: ".$path);

3 Responses to “lighttpd文件下载实现”

  1. 神仙 |

    $path是啥?服务器上的路径吗?
    这样会不会暴露服务器路径呢

    [回复此评论]

    小路 reply on 2008-03-03:

    你可以用相对路径试试,这我没试验过…另外..response我也没有试过截获过,据说是不会生成X-LIGHTTPD-send-file: 的response

    你若试过了,请把信息反馈给我,呵呵

    小路 reply on 2008-03-03:

    $path是服务器的绝对路径没错..

Leave a Reply

 

Bad Behavior has blocked 926 access attempts in the last 7 days.