adding a download link for a local pdf file isn't working

Viewed 659

I'm trying to add a link for anyone to download my resume on my site. This is what I have

<a  href="My Resume.pdf" class='download' download="Resume PDF">Download CV</a>

I believe this is the right format, but it isn't working when I click on the link. The file always attempts to download as an HTML rather than a PDF and fails. Is it because I'm still on the localhost server? Will it be fine when I go public? (I am using angular, by the way, and had to install an extension for the file to be read in VS code.)

2 Answers

Three Things to Check:

  1. Remove the download attribute. You probably don't need it. If you want the PDF to open in a new tab for the user, you can add the target attribute: target="_blank"

  2. Generally it's safer to name the file without spaces, as not all web servers parse spaces the same. Have you tried naming the file MyResume.pdf instead, and have you had the same results?

  3. The next thing to check would be to ensure the file is in the same directory as where the page loads. Are you certain about the file's location?

Instead of specifying the file to download with the download attribute:

<a href="My Resume.pdf" class='download' download="Resume PDF">Download CV</a>

Set the download attribute to download, like this:

<a href="My Resume.pdf" class='download' download="download">Download CV</a>

OR

specify the download attribute and leave it blank without assigning anything:

<a href="My Resume.pdf" class='download' download>Download CV</a>

Both of these methods should work.

Here is a short explanation: When specifying the download attribute, this tells the browser to download the file specified with the href attribute.

Related