I am currently working on a personal portfolio, I am trying to make a button that if you click it should download a Resume.
code
<form method="get" action="fileName">
<button class="myButton" type="submit">Download!</button>
</form>
let the user download the file.
I am working in REACTJS, create-react-app
You can use FileSaver.js to achieve this goal:
Install the npm package: npm install file-saver --save
const saveFile = () => {
fileSaver.saveAs(
process.env.REACT_APP_CLIENT_URL + "/resources/cv.pdf",
"MyCV.pdf"
);
};
<button className="cv" onClick={saveFile}>
Download File
</button>
you can do it by this way
<a href="./yourfile.pdf" download>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