Designing a button by html and css is easy. I am a beginner in front end development still I don't know how to make a button work, as like downloading pdf and img files.
If I can get a code form anyone it will be very helpful for me.
CodePudding user response:
After a bit of digging, I found this:
<a href="dashboard.php" download="cookie-policy.txt">
<button type="button">Download</button>
</a>
You have to include the href
bit but it won't redirect you to a page, it's just there. To work, both the resource linked to using href
and the file to download must be in the same directory if you don't use absolute paths.
The button is only there to make the anchor look like a button; you can simply use CSS to make the anchor look like a button.
CodePudding user response:
I had used this beforehand. So feel free to try it.
<button type="submit" onclick="window.open('file.doc')">Download!</button>
It should work on most places.You just add the file loacation window.open(here)
But if it doesn't please provide a bit more information about your project so that I can understand how to work with it.