mattgadient.com

Trying to download files but they show as garbage characters – fixing your website.

Just about everyone’s seen this issue at some point or another. It’s a pain when it happens on your own site though. You click a link, expecting a download to start, and low and behold you simply get a new webpages with a pile of garbled text.

Reason: For whatever reason, the MIME type of that file’s extension isn’t set on the server.

The Fix: The most simple way for most is to simply edit your .htaccess file. Add the following line:

AddType application/octet-stream zip

Replace zip with whatever the extension is. So if it’s.. warcraft maps for instance (mapname.w3x), use AddType application/octet-stream w3x. If it’s a .msu file, AddType application/octet-stream msu . And so on. What this will do is force the viewer’s browser to download whatever the file happens to be.

There are other ways to set the MIME type, but .htaccess is generally available to most people whether they’re on shared or dedicated hosting. In the event you’re using a webserver that supports .htaccess, ask your host how to change MIME types in your particular environment.