Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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>

Brandon Gormley
Brandon Gormley
6,147 Points

Hmmm, didn't seem to work :/

1 Answer

Sean T. Unwin
Sean T. Unwin
28,660 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,660 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.