如何使用PHP显示“另存为”对话框的文本文件 [英] How to show 'Save as' dialog box using PHP for text files
本文介绍了如何使用PHP显示“另存为”对话框的文本文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何使用PHP显示另存为对话框,该对话框会要求用户将字符串下载为文本文件?基本上我会从数据库中检索一些值,然后希望能够下载包含这些数据的.txt文件。
How can I show the 'Save as' dialog box using PHP which will ask the user to download a string as a text file? Basically I will retrieve some values from the database, and want then to be able to download a .txt file which contains this data.
推荐答案
这应该有效:
header('Content-type: text/plain');
header('Content-disposition: attachment; filename="test.txt"');
这篇关于如何使用PHP显示“另存为”对话框的文本文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文