【问题标题】:How to open files from a remote server using HTML [duplicate]如何使用 HTML 从远程服务器打开文件 [重复]
【发布时间】:2018-07-25 18:06:10
【问题描述】:

有没有使用 HTML 从远程服务器打开文件的选项?

我目前正在使用“文件”协议,但它不再受支持,我被卡住了,因为我找不到使用 HTML 打开它的解决方案。

这是我当前的代码

<a href="file://\\SERVER\files\file.pdf" target="_blank">Open File</a>

【问题讨论】:

  • 当你说“开放”时,你到底是什么意思?您想在浏览器中打开文件吗?
  • 您不能远程使用file:///,您需要一个标准的http://,然后该服务器需要为您找到它并将其传回,所有这些都使用服务器端代码完成。
  • 是的,我希望它在浏览器中打开。
  • 那么现在没有办法通过HTML打开了吗?只在我的远程服务器上设置一个网络服务器来访问它

标签: html file remote-server


【解决方案1】:

如果您没有定义绝对地址,html 将在您的页面托管的服务器中搜索文件。

 //It means that there is a folder named images on the same location of your html page.
 <a href="/images/myFile.jpg">

 //It means that there is a folder in the parent folder of your html page named images on the same location of your html page.
 <a href="../images/myFile.jpg">

或者您可以定义一个绝对地址来下载或打开您的文件:

  <a href="http://yourdomain.com/images/myFile.jpg">

【讨论】:

  • 请说为什么不投反对票,投反对票没有任何意义。我相信有些人只是因为投反对票而投反对票。
猜你喜欢
  • 1970-01-01
  • 2012-04-08
  • 2017-09-22
  • 2020-11-01
  • 2016-04-19
  • 2011-12-28
  • 2015-06-16
  • 1970-01-01
  • 2013-11-12
相关资源
最近更新 更多