简体   繁体   English

创建打开位于服务器上的文件的链接 (HTML)

[英]Create a link which opens a file located on a server (HTML)

I have coded a bit in Java and Ada, but I am completely new to HTML so I'm asking for some help here.我在 Java 和 Ada 中编写了一些代码,但我对 HTML 完全陌生,所以我在这里寻求帮助。

A friend of mine (without any coding experience, whatsoever) is setting up a website for his new business, and he asked me to help him.我的一个朋友(没有任何编码经验)正在为他的新业务建立一个网站,他要求我帮助他。 What he wants is a link on his website which downloads a PDF file, or opens the file in a new tab, ie the user clicks the link and downloads/opens the PDF file.他想要的是他网站上的链接,该链接下载 PDF 文件,或在新选项卡中打开文件,即用户单击该链接并下载/打开 PDF 文件。 Ideally, this file will be located on his computer/server.理想情况下,该文件将位于他的计算机/服务器上。 As the website is made on Wix.com, and as neither one of us has any experience with HTML I have only tried to add code in its built-in "editor".由于该网站是在 Wix.com 上制作的,而且我们都没有任何使用 HTML 的经验,因此我只尝试在其内置的“编辑器”中添加代码。

I've googled for a bit, and I have added a link which opens a PDF file using a URL.我用谷歌搜索了一下,我添加了一个链接,该链接使用 URL 打开 PDF 文件。

It looks like this:它看起来像这样:

<a href="https://www.googledriveorsomething.com/document.pdf" target="_blank">Name of the document</a>

What I want to do is something like this:我想做的是这样的:

<a href="servername/document.pdf" target="_blank">Name of the document</a>

Is something like this possible?这样的事情可能吗? How do I reach the file?我如何到达文件? Is it possible to have the file stored on the hard drive on his computer/server?是否可以将文件存储在他的计算机/服务器上的硬盘驱动器上? Or does it have to be stored in some cloud-based system?还是必须将其存储在某些基于云的系统中?

Also, this is a sort of quick fix, until he has the resources to hire a professional for the task.此外,这是一种快速解决方法,直到他有资源聘请专业人士来完成这项任务。

You can use an html attribute where you specify that link to file is downloadable as follows:您可以使用 html 属性在其中指定文件链接可下载,如下所示:

<a href="servername/document.pdf" download>Clickable text</a>

also you can use it as follows of you want to download it with a specific name:您也可以按以下方式使用它,如果您想以特定名称下载它:

<a href="servername/document.pdf" download="PDF Filename">Clickable text</a>

About where the file is located, you should upload it to a web server to make it available to others.关于文件所在的位置,您应该将其上传到 web 服务器以供他人使用。 If it's located in your friend's computer, it won't available to others.如果它位于您朋友的计算机中,其他人将无法使用它。

暂无
暂无

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

相关问题 如何链接位于另一个文件夹中的 HTML 文件中的 CSS 文件 - How to link a CSS file in HTML file which is located in another folder 在浏览器中打开链接的HTML文件 - HTML file that opens a link in a browser 我的链接打开了 html 文件,但以一种解除配置的方式 - My link opens the html file, but in a deconfigurated way 如何创建在.php表中打开链接的HTML按钮? - How can I create a HTML button that opens a link in a .php table? 如何使用Meteor本地服务器创建指向html文件的链接? - How to create a link to a html file using the Meteor local server? Mobile Safari-HTML下载链接打开标签页,而不是下载文件 - Mobile Safari - Html download link opens tab instead of downloading file 从子文件夹中的文件中获取HTML输入值? - Get a HTML input value out of a file which is located in a subfolder? Raspberry Pi 服务器,显示位于单独 Html 文件中的表的问题 - Raspberry Pi server , Problems showing a table that is located in a seperate Html file Bootstrap 4:在折叠的手风琴卡片中创建指向 ID 的直接链接,然后打开卡片并跳转到 ID - Bootstrap 4: Create a direct link to an ID inside a collapsed accordion's card which then opens the card and jumps to the ID 我如何创建一个固定的按钮,当使用HTML和CSS单击该按钮时会打开一个联系表单? - How do I create a fixed button which opens a contact form when clicked using HTML & CSS?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM