Main Content

FTP - how not to corrupt data (binary v ascii)

Archive - Originally posted on "The Horse's Mouth" - 2008-06-24 22:25:46 - Graham Ellis

Greetings from Aylesbury ... where I am spending much of this week during the day giving a Linux (LAMP) course, and much of the evening catching up on work. So just a brief tip today ..

If you're transferring files with FTP, remember to specify Binary mode!.

Perhaps advise you've heard before and not fully understood why or perhaps - like most of us - something you've heard, forgotten, and then transferred a file to find that your hard-gotten data is corrupted.

In the default (ASCII) mode of transfer between windows and Linux / Unix systems, FTP translates new line sequences c/r, l/f to just l/f, or vice versa - thus effectively corrupting zip files, tar files, etc. It's made the worse by the fact that the mapping doesn't exactly reverse when you transfer the file the other way ... so a transfer from Linux to Windows in ASCII, followed by a transfer back also in ASCII leaves you with a corrupted file