我正在使用以下代码将 textarea 内容保存为 .txt 文件。它将创建一个 test.txt 文件。
function feed_text_download(){
if(isset($_POST['text_to_download']))
{
header('Content-disposition: attachment; filename=test.txt');
header('Content-type: application/txt');
echo $_POST['text_to_download'];
exit; //stop writing
}
}
add_action('after_setup_theme', 'feed_text_download');
我需要以这样的方式更改代码,一旦我点击保存按钮,我会得到 save as
框,用户可以选择文件名而不是 test.txt。我在这里需要帮助。