简体   繁体   English

使用PHP将文件保存到特定位置

[英]Save File to Specific Location Using PHP

I have a PHP script that is writing an Excel file. 我有一个写Excel文件的PHP脚本。 The script is successfully writing the file, but is saving it in the same directory as the script. 该脚本已成功写入文件,但将其保存在与脚本相同的目录中。

I want the user to be able to see the "Save As" dialog window when they click the Download button that I have. 我希望用户单击我具有的“下载”按钮时能够看到“另存为”对话框窗口。 Everything I have seen regarding how to do this in PHP has said to just add this to the PHP script: 我所见过的有关如何在PHP中执行此操作的所有内容都表示只需将其添加到PHP脚本中即可:

header('Content-Disposition: attachment; filename="video.m4v"');

where "video.m4v" would be the Excel file I am downloading. 其中“ video.m4v”将是我正在下载的Excel文件。

However, the "Save As" window never pops up, and it continues to save it to the same directory as the script. 但是,“另存为”窗口永远不会弹出,并且会继续将其保存到脚本所在的目录中。 Can anyone please tell me how to do this? 谁能告诉我该怎么做?

you can use 您可以使用

<a href="video.m4v" download>Click here to download</a>

be sure to include the word "download" after the filename 请确保在文件名后包含“下载”一词

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM