PHP create file for download without saving on server

六月ゝ 毕业季﹏ 提交于 2019-11-28 04:41:44

Instead of saving it to a file, just echo it after you send the headers.

Realize that nearly every time a PHP script responds to a request, it's "generating a file" that's downloaded by the browser. Anything you echo, print, printf, or otherwise put out to standard output is the contents of that "file".

All you have to do is tell the browser that the "file" should be handled differently -- and the headers you're outputting should already do that. Once the headers are sent, anything you print out becomes contents of the download.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!