在CKEditor中,我有一个非常基本的页面,上面有一个表单。该表单有一个元素-textarea,我的用户可以在这里创建HTML
我希望我的用户能够点击屏幕上的一个按钮,"另存为"框就会打开,可以将该文本区域的内容保存到本地服务器上的HTML文件中。
到目前为止,我的代码基本上就是这样:
<form method="post">
<textarea name="editor1"></textarea>
<script>
CKEDITOR.replace("editor1");
</script>
<input type="submit">
</form>
您可以将文本发布到php文件中。
在php文件中,您设置了以下标题:
header("Content-Description: File Transfer");
header("Content-Disposition: attachment; filename=somename.html");
header("Content-Transfer-Encoding: binary");
header("Content-Type: application/force-download");
之后,您只需从编辑器中输出html即可。