Home > Net >  Downloading a pdf in react with a button?
Downloading a pdf in react with a button?

Time:07-13

I have an anchor tag (a href) defined with the path for my resume. The resume is in the public folder in a folder but when i click on the "My CV" button all i get back is Failed no file?

The anchor tag and button

files & folders

CodePudding user response:

just checked on my code, seems you need to place a tag inside the button not above:

<button>
    <a
        href='/pathToPdf.pdf'
        target='_blank'
        rel='noopener noreferrer'
    >
        RESUME
    </a>
</button>

CodePudding user response:

As i see remove {} from href attribute because it's not JavaScript code then in download meta-attribute you should put your file extenstion ".pdf"

 <a
 href="./public/file.pdf"
 download="mycv.pdf">
 Save
 </a>

</button>
  • Related