Tuesday, February 22, 2011

epub files downloading as zip files

Recently I added epub versions of my free reads to my website (here). I did due diligence, or so I thought. I created the files and tested them. I added them to the page as downloads, uploaded, and then tested the downloads again. Usually I would do all this testing in all browsers, but since this was a simple click to download, I didn't (shame on me). Everything worked fine in Firefox for me, but today I was contacted by someone who ran into a problem.

When my website visitor tried to download the .epub version in Internet Explorer, it tried to save it as a .zip file. I did some research and thought I'd share how I fixed it, in case you are like me and would like to post .epub digital books on your website--and in case you run into this problem.

The basic issue is that the web server doesn't know what an .epub file is. You need to tell it to treat it in a certain way. On your server, there is likely a .htaccess file in the root directory of your website. If not, you can create one. It just needs to be a text file named ".htaccess"

In that file, you need these two lines:
AddHandler application/epub+zip .epub
AddType application/epub+zip .epub

I'd also recommend changing your link to your .epub file to include a type. Here's my code as an example:
<a class="link" href="http://www.elladrake.com/freereads/Grounded%20-%20Ella%20Drake.epub" title="Grounded" type="application/epub+zip">epub</a>

That's it! If you have this problem & this doesn't work, leave a comment, and I'll see if I can help.

No comments: