<<< Home << Web < HTML Notes Top Bottom < Prev Next >

FTP - Binary vs. Ascii Mode

Topics on this page

  1. Binary mode
  2. Ascii mode
  3. Automatic mode detection

Binary Mode

When you send data using binary mode, the data is transmitted exactly as it is. You need to use binary mode to send files such as graphics or midis in binary mode so that your FTP program doesn't change anything.

Ascii Mode

When you send data using ascii mode, the data is may be modified in various ways. You need to use ascii mode to send text files such as .htm, .txt, .css and .js files.

The most obvious change that the FTP program makes to the file is for the end-of-line characters. In a text file, each line of data has one or two characters at the end that marks the end of the line. On Unix machines, a LF (line feed) character is used for this. On Macs, a CR (carriage return) character is used. On DOS and Windows machines, both a LF and a CR are used. Your FTP program knows what type of machine you're using, and you tell it what type of machine you're sending to. It automatically changes the end-of-line characters for you.

If you try to send a binary file such as a graphic using ascii mode, any bytes that just happen to match the code for a LF or CR might get translated to something else. This is why you must use binary mode to transmit those types of files.

An historical note

The LF and CR characters go back to the days of teletype terminals. These were similar to typewriters. A LF character simply moved the paper down a line without changing the horizontal position of the typing ball. A CR character moved the ball to the beginning of the line.

Most of the time, you'd want to send both a LF and a CR to begin a new line of printing. However, there were times when you'd just want to use one or the other.

To double-space, you'd send two LF characters but just one CR character - there was no need to do the CR function twice.

To get extra emphasis on a line, you could send just a CR and resend the line you just printed. The line would appear bold compared to lines that weren't typed over in this manner.

Automatic mode detection

Your FTP program can probably choose the correct mode automatically for you. I use WS-FTP Pro for Windows, so my instructions here are for that program. If you use a different FTP program, it probably has a similar feature.

Main WS-FTP window

Make sure the "auto" checkbox is checked to get automatic detection.

Use the "options" button to set up the file types for automatic detection.

When you click on the "options" button, the following window pops up:

Options - Extensions

In the extensions tab, specify which file types are to be sent in ascii mode. All other types are sent in binary.

To add an extension, type it into the box next to the "add" button and then click on the "add" button.


<<< Home << Web < HTML Notes Top Bottom < Prev Next >