I'm trying to create button that if I click it should download the file. I work on Next js
<a href={cv} download="name cv.pdf"> Download CV </a>
I did this code in react and run correctly but when I try it in next js I get "Failed - No file". I'd like to figure out what's causing this issue
I assume you are trying to serve a static pdf file in your nextjs project.
Please make sure the file is in public/
folder.
For eg., let's assume the file is placed in public/cv.pdf
.
Then, the anchor tag should be
<a href="/cv.pdf" download="cv">Download CV</a>
If you're trying to serve from a cdn, please ensure the cdn link is valid.
<a href="https://mycdn.com/assets/cv.pdf" download="cv">Download CV</a>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With