将 Href 设置为服务器路径

发布于 2024-09-25 18:25:38 字数 130 浏览 0 评论 0原文

如何正确将 Href 设置为服务器上的文件(例如:\myserver\test\a.txt)?当我将路径分配给 Href 时,它在前面添加了域名(http://mydomain.com/myserver/test/a.txt),这不是正确的路径。

How do I set Href to a file on a server (example: \myserver\test\a.txt) correctly? When I assign the path to Href, it adds the domain name in front (http://mydomain.com/myserver/test/a.txt) which is not the correct path.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

糖粟与秋泊 2024-10-02 18:25:38

尝试使用 file:/// URI 范例。例如,我可以在浏览器中访问 file:////sharename/c$/ 并且它可以工作。

Try using the file:/// URI paradigm. For example, I can go in my browser to file:////sharename/c$/ and it works.

阳光下的泡沫是彩色的 2024-10-02 18:25:38

您无法从客户端从服务器下载文件。您必须在服务器端执行此操作,或者确保可以通过将要在 href 中提供的文件添加到托管目录中来访问该文件。

如果您不想手动移动服务器上的文件,更好的方法之一是在服务器端编写代码,从您指定的服务器上的任何位置复制该文件,并将其放入托管目录中。文件位于托管目录中后,您可以创建一个链接并将其提供给用户下载或访问。

You can't download a file from server from your client side. You have to do this on your server side or make sure that the file which you want to give in href is accessible by adding it in your hosted directory.

One of the better way if you dont want to manually move the files on server is to write code on server side to make a copy of that file from any location on that server as specified by you and put it in hosted directory. Once the file is in hosted directory you can create a link and give it to user for download or access.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文