首頁 >後端開發 >php教程 >對word直接從資料庫查詢進行下載

對word直接從資料庫查詢進行下載

WBOY
WBOY原創
2016-07-25 08:49:37864瀏覽
  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. }
复制代码


陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn