tags:

views:

104

answers:

1

Hello,

When I upload/download some HTML/CSS/… file to FTP server, sometimes something puts every line of code in one line making it completeply unreadable. That something happens every now and then and I’m still looking for an explanation for this behaviour. What could cause this?

+5  A: 

It has to do with text file line endings and FTP transfer modes.

  • Text files in Windows use a combination of carriage return and line feed at the end.
  • Text files in Mac OS9 and down use carriage return only.
  • Text files in UNIX and its clones (including OSX) use line feed only.

It sounds like you're pulling a UNIX-style text file to a Windows system in binary mode and then trying to view it in an editor that doesn't understand these differences.

FTP clients have an ASCII (or ASC) transfer mode to do these conversions for you. It's not usually turned on by default, though, as it messes up binary files.

Two solutions are to use an editor that understands the differences or use an FTP client that allows you to tell it that specific file extensions should be transferred in ASC mode.

P.S. This is probably better asked on superuser or serverfault.

R. Bemrose