Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialBrandon Gormley
6,147 PointsDownload Button will only open in browser?
Hey guys,
My goal is to click a Download Button which I have made and then have my resume download to the user's computer. Currently it will only open up in the browser.
Anyone know how to fix?
-Thank you,
<div class="resume"> <h2>Resume</h2> <p>Please feel free to download my resume below:</p> <a class="resumebutton" href="resume/resume.pdf" download="Resume">Download</a> </div>
Brandon Gormley
6,147 PointsHmmm, didn't seem to work :/
martinjones1
Front End Web Development Techdegree Graduate 44,824 PointsOK, could be worth checking if your browser can use this attribute using the link below:
https://caniuse.com/#feat=download
If not, please post the updated HTML your are using and I will take a look
1 Answer
Sean T. Unwin
28,690 PointsDepending on your web server, you may have to set the Response Headers.
For example, if you are using Apache you may set the following in an .htaccess
:
AddType application/octet-stream .pdf
There are other ways to perform essentially the same, i.e. setting the headers, programmatically in whichever language you are using on the server.
Brandon Gormley
6,147 PointsWhere would I add this to in the html?
Sean T. Unwin
28,690 PointsIt wouldn't go in your HTML as it's a web-server configuration to force downloads for particular file types. This is because Response Headers are sent from the web-server.
martinjones1
Front End Web Development Techdegree Graduate 44,824 Pointsmartinjones1
Front End Web Development Techdegree Graduate 44,824 Pointsjust change
download="Resume"
to just
download
and you will be OK.
Hope this helps,
Further info is available at https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a#Attributes