通过Html按钮打开文件

Open A File Via Html Button

本文关键字:文件 按钮 Html 通过      更新时间:2023-09-26

我正在寻找一种方法来打开一个文件,当用户点击打开按钮在我的网站。

基本上,我想定义路径到特定的文件,我希望html按钮打开

我在另一篇文章中读到过。试试这样:

<a href="path_to_file" download="proposed_file_name">Download</a>

地点:

path_to_file是绝对路径或相对路径,Proposed_file_name要保存的文件名(可以为空,然后默认为实际文件名)。

希望有所帮助

<a href="/filepath/file.pdf" target="_blank"><input type="button" value="Open File" /></a>

使用

<input type="file" id="file" name="file" />

可以打开一个文件对话框。您必须使用PHP来处理这个问题。这个链接:https://www.sitepoint.com/handle-file-uploads-php/提供了你需要的所有信息。如果没有可以上传.php文件的服务器,可以设置一个LAMP服务器。

希望这对你有帮助