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 trial

HTML

Brandon Gormley
Brandon Gormley
6,147 Points

Download 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>

just 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

Brandon Gormley
Brandon Gormley
6,147 Points

Hmmm, didn't seem to work :/

OK, 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
Sean T. Unwin
28,690 Points

Depending 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
Brandon Gormley
6,147 Points

Where would I add this to in the html?

Sean T. Unwin
Sean T. Unwin
28,690 Points

It 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.