龙盟编程博客 | 无障碍搜索 | 云盘搜索神器
快速搜索
主页 > web编程 > php编程 >

php 对word直接从数据库查询进行下载

时间:2014-07-08 15:00来源:网络整理 作者:网络 点击:
分享到:
对word直接从数据库查询进行下载 [代码片段(25行)]
function save($word_name)
{
    echo "</html>";
    $data = ob_get_contents();
    ob_end_clean();
    $this->wirtefile ($word_name,$data);
}

function wirtefile ($word_name,$data)
{
    $path = 'public/uploads/'.$word_name;
    $file = fopen($path,"wd");
    fwrite($file,$data);
    fclose($file);
    $file = fopen($path,"r");
    Header("Content-type: application/octet-stream");
    Header("Accept-Ranges: bytes");
    Header("Accept-Length: ".filesize($path));
    Header("Content-Disposition: attachment; filename=".basename($path));
    echo fread($file, filesize($path));
    fclose($file);
    unlink($path);
    $this->index();
}
//该片段来自于http://outofmemory.cn
精彩图集

赞助商链接