python - Django后台生成下载文件
PHP中文网
PHP中文网 2017-04-18 10:30:50
0
1
568

就是界面上有个按钮,然后点击之后,后台会生成一个文件,比如log文件,然后当生成完成,就可以下载了。
由于第一次处理这种实时文件生成,不太明白怎么实现。谢谢

PHP中文网
PHP中文网

认证0级讲师

reply all(1)
左手右手慢动作

Return a downloadable file. As long as you add Content-Disposition=attachment; filename="anyfilename.xxx" in the header of the returned HTTP response, the browser will pop up a download dialog box to prompt the user to download.

The file content background is the same whether it is read from a local file or a string produced by a program. It is stuffed into the HttpResponse object and returned in the corresponding view. Be careful not to keep users waiting for too long.

For an official example of generating a csv file, please refer to: https://docs.djangoproject.co...

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!