E-book download garbage screen

This is about an occasional problem I’ve seen with e-book downloads. When you click the download link (as opposed to using the context menu to explicitly save the file), it opens in the browser, but the contents are garbage characters.

EPUB download attempt makes browser display screen of garbage.

This isn’t a problem with the visitor’s computer. It happens because your web server isn’t set up to handle the e-book file format. The server tells the browser, “I’m sending a plain text file,” and the browser thinks it knows how to display that. But it is a dirty lie. Because it isn’t really a plain text file, the browser makes a hash of it.

There are three ways to fix this — the easy way, the somewhat less easy way, and the cowboy way.

The Easy Way

I mean, the server is set up wrong. It shouldn’t be up to you to fix it. Contact your web hosting provider and tell them this:

My server isn’t set up correctly to handle ____ files. When a browser downloads the file, the server claims the MIME type is plain text. Please fix this. In fact, please fix it on all your servers. These are common file types which you should handle correctly by default.

You, to website hosting tech support.

This assumes it really is a common file type (in case you found this page while trying to set up download of some other kind of file besides e-books). If this doesn’t get you a solution, consider switching to a different hosting company. See my current web hosting recommendations.

When they tell you it’s fixed, before you try it again, clear your browser’s cache. I said cache, not cookies. You won’t lose any information or get logged out of sites by doing this. Because your browser saved the incorrect file information from your previous attempt, to save time, it won’t even ask the server to resend the file. Instead it just uses its saved copy. “Cast that incorrect file from your memory,” you must command the browser.

The Somewhat Less Easy Way

In some cases, you can fix this yourself through your web hosting provider’s “control panel”. Search the menus for MIME. If you find a MIME types tool, use it to add the file types you need. This screenshot is just an example — YMMV.

Adding a MIME type to your website
Extension(s)MIME type
epubapplication/epub+zip
azw and azw3application/vnd.amazon.ebook
mobiapplication/x-mobipocket-ebook

If the file type you’re having trouble with isn’t in the above table, search the internet for MIME type xxx where xxx is the file extension.

Save your changes, clear your browser cache, and try the download again.

If you find this website helpful, why not…

Subscribe for email updates

Your information will not be shared (except with MailChimp, who manages the subscriber list).

The Cowboy Way

If your hosting provider doesn’t give you an easy way to add MIME types, you can definitely do it by editing the file .htaccess in your server’s file system using the File Manager tool from the hosting provider’s cPanel / Site Tools / Manage Website screen.

Warning: use caution editing this file; you can break your website if you get it wrong. Make a copy of the file first so you can restore it if needed.

Shows how to use context menu to copy .htaccess in File Manager

There’s a separate .htaccess file for each website hosted in your account. Since it’s a special file, the File Manager may hide it unless you specifically ask for hidden files to be displayed. It’s in the same folder as the WordPress file wp-config.php (among many others). File Manager should give a way to edit the file online. Copy and paste the file to create a backup before you pull out your six-shooter.

Add these lines at the end of the file:

 AddType application/vnd.amazon.ebook azw azw3
 AddType application/epub+zip epub
 AddType application/x-mobipocket-ebook mobi 

You can see the pattern; AddType, then the MIME type, then a list of the file extensions for that MIME type, all separated by spaces. If you search the web, you’ll find examples of AddType with a period before the file extension (“.azw” rather than “azw”). Either way works.

The file will probably contain lines #BEGIN WordPress and #END WordPress. Because WordPress occasionally replaces everything between those tags, don’t add your lines there, or WordPress will clobber them.

Once again, clear your browser cache before retesting the download.

Share...

Leave a Reply

Your email address will not be published. Required fields are marked *