简体   繁体   中英

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.

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. 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".

I've googled for a bit, and I have added a link which opens a PDF file using a URL.

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:

<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. If it's located in your friend's computer, it won't available to others.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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