Data Type

From FileZilla Wiki
Revision as of 19:56, 23 July 2007 by Otacon (talk | contribs) (added)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search

Transfer Mode

The FTP protocol knows two modes for transferring files: ASCII mode and binary mode.

ASCII mode is used to transfer text files. The problem with text files is that different platforms have different kinds of line endings. Microsoft Windows for example uses CR (carriage return) and LF (line feed), while Unix only uses LF and traditional MacOS uses only CR. The task of ASCII mode is to make sure that line endings are properly changed to what is right on the platform. According to the FTP specification, ASCII files are always transferred using CR LF as line ending.

So in case the file is transferred from the client to the server, the client has to make sure CR LF is used. Therefore it has to add nothing (on Microsoft Windows), add CR (on Unix) or add LF (on MacOS) to each line ending. The server then adjusts the line ending again to what is used on the platform the server runs at. If it is Microsoft Windows, nothing has to be removed, while on Unix the superfluous CR is removed and on MacOS the unneeded LF.

The same happens when a file is transferred from the server to the client: the server makes sure the line endings are CR LF and the client then strips away whatever is not needed as line ending on its platform.

Because the file is changed if client and server are not running on the same kind of platform, this transfer mode cannot be used for files with any possible character, so called binary files, like images and videos. If it is used anyway, the binary files most likely are corrupted and won't work as expected anymore.

Compared to ASCII mode, binary mode is the easier one: the file is just transferred as-is, and not line ending translation is done.

So when you are not sure what to use, always go for binary mode. Nowadays, nearly all (good) text editors can handle the three possible line endings, and other textual files like the ones of scripting languages such as Perl or PHP, as well as XML files (nearly) always work with any line ending as well.