Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/file/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
PHP:带有自定义内容的另存为对话框_Php_File_Content Disposition_Save As - Fatal编程技术网

PHP:带有自定义内容的另存为对话框

PHP:带有自定义内容的另存为对话框,php,file,content-disposition,save-as,Php,File,Content Disposition,Save As,我有以下代码: header('Content-type: text/plain'); header("Content-Disposition: attachment; filename=bookmark.adr"); readfile('bookmark.adr'); 这将生成一个“另存为”弹出窗口,用户可以在其中保存bookmark.adr文件。但我想自定义生成该文件的内容。如何生成内容并将该文件作为另存为弹出 谢谢 只是不要做readfile()。回显您希望该文件包含的任何内容 您的内容

我有以下代码:

header('Content-type: text/plain');
header("Content-Disposition: attachment; filename=bookmark.adr");
readfile('bookmark.adr');
这将生成一个“另存为”弹出窗口,用户可以在其中保存bookmark.adr文件。但我想自定义生成该文件的内容。如何生成内容并将该文件作为另存为弹出


谢谢

只是不要做
readfile()
。回显您希望该文件包含的任何内容


您的
内容配置
标题将告诉大多数浏览器提示用户保存文件。

@Jordy,哪个页面的源代码?您的文件将包含您所回显的内容。如果那是HTML,那就是文件中的内容。啊,我知道了。非常感谢:最后一个问题。.adr文件的内容类型应该是什么?@Jordy,我不熟悉
adr
文件,但一些快速的谷歌搜索建议
text/directory