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

PHP save file without save as dialog

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

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

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

那么我该如何实现呢?

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

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

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