wirtefile ($word_name,$data);} functi">
当前位置:Gxlcms > PHP教程 > 对word直接从数据库查询进行下载

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

时间:2021-07-01 10:21:17 帮助过:25人阅读

<无详细内容>
  1. function save($word_name)
  2. {
  3. echo "";
  4. $data = ob_get_contents();
  5. ob_end_clean();
  6. $this->wirtefile ($word_name,$data);
  7. }
  8. function wirtefile ($word_name,$data)
  9. {
  10. $path = 'public/uploads/'.$word_name;
  11. $file = fopen($path,"wd");
  12. fwrite($file,$data);
  13. fclose($file);
  14. $file = fopen($path,"r");
  15. Header("Content-type: application/octet-stream");
  16. Header("Accept-Ranges: bytes");
  17. Header("Accept-Length: ".filesize($path));
  18. Header("Content-Disposition: attachment; filename=".basename($path));
  19. echo fread($file, filesize($path));
  20. fclose($file);
  21. unlink($path);
  22. $this->index();
  23. }

人气教程排行