- 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://www.codesnippet.cn/detail/130120148486.html
来源: http://www.codesnippet.cn/detail/130120148486.html