PHP保存文件而不保存为对话框

时间:2015-05-05 06:28:09

标签: php content-type savefiledialog

我正在使用PHP创建MS Office Word文档,如下所示:

header("Content-type: application/vnd.ms-word");
header("Content-Disposition: attachment;Filename=filename.doc");
header("Content-Transfer-Encoding: binary");

但我需要将文件保存到服务器而不保存为对话框,以便能够对创建的*.doc文件执行某些操作,并仅在修改后将其提供给用户。

那我怎么能实现这个呢?

1 个答案:

答案 0 :(得分:0)

您使用的代码是将下载发送给浏览器用户 要在服务器上保存,请在PHP中使用它:

file_put_contents('path/to/ms/word/document.doc', $theData);

然后在使用代码发送保存的文件后。