Ascii or Binary?

The general rule of thumb is if you can view the file in a text editor like notepad (ie. .html, .js, .css files etc) you should upload in ASCII mode, most others (including images, sound files, video, zip files, executable's etc) should be uploaded in Binary.

Exceptions to the Rule

It seems all things related to computers have exceptions to the rules. Yes, this is yet another case of it.

If your text files contain international characters (ie. Chinese or Japanese text), they may have to be uploaded as binary. The reason is that ascii takes into account differences between DOS and UNIX files (7 bits) but it doesn't do well with text using higher bits.

Why Does It Matter What Mode You Transfer Files With?

If you upload images etc. as ascii you'll end up with corrupted files. Some browsers seem capable of figuring it out, but not all... and not all the time. Netscape is much more picky, so you'd end up with broken or missing pictures for your Netscape users. (Yup, I learned this the hard way :-o )

Same thing with uploading text files as binary. While this is less important for html files, scripts will have a HUGE problem with it and will just not work. This is the most common cause of the "Server 500 Error - Malformed Headers", and other equally unlovely errors that have caused many a webmaster to bang their heads against their computers.

So What Does Uploading In ASCII Do?

I'd wondered this for a while and finally decided to learn why uploading in ascii is so important for some file types. What I found out is that different Operating System's use different ways to specify that a line has ended. So if you're using a different operating system than your server (which is very likely), the files will have extra characters at the end of each line that the server doesn't recognize. So it'll usually print them out resulting in script errors.

Setting Your FTP Program to "Auto"

Most FTP programs have the option to set your upload to auto. What this usually does is compare the file type you're transferring against a list of known file types and set it to binary or ascii upload on its own.

By default, most FTP programs will have a pre-set list of files to be transferred in ascii and will upload / download everything else in binary. (These settings are in different places depending on the program you are using. Check the "Read Me" file or their Website if you can't find it.) Be sure to double check that the files you want to transfer are in the appropriate list.


.htm .html .shtml .php .pl .cgi .js .cnf .css
.forward .htaccess .map .pwd .txt .grp .ctl

Binary Files
.jpg .gif .png .tif .exe .zip .sit .rar .ace
.class .mid .ra .avi .ocx .wav .mp3 .au