52

I'm downloading a perl CGI file from a Linux web server.

It has Unix linebreaks. I edit it on a Windows PC with a decent text-editor (Geany) which preserves those linebreaks.

I then upload it again with Filezilla and it has DOS linebreaks, which stop it working.

I know it's Filezilla, not Geany because even if I just download it, and re-upload it, the problem recurs.

Filezilla asks me, every time, if I'm OK to upload the local file (3611) bytes and overwrite the remote file (3753 bytes), and the difference between those numbers is the number of lines in my file. But when I do that, the one on the server is 3753 bytes all over again and doesn't work.

I'm going through a proxy server, might that be a factor? The really weird thing is I did the same thing on a different XP PC just the other day and it was fine. And command-line FTP works fine too.

innaM
  • 47,505
  • 4
  • 67
  • 87
AmbroseChapel
  • 11,957
  • 7
  • 46
  • 68
  • I just wasted 3hrs trying to find what is wrong with the files when uploaded due to this. Once I changed it to BINARY, it will now works. someone at ftpzilla should really change the default to BINARY after all these years! – Nasser Mar 29 '22 at 09:35

4 Answers4

136

In FileZilla 2.2.32, go Edit > Settings > File transfer settings > ASCII/Binary. Set it to always binary: that should do the trick.

In FileZilla 3.5.0 the setting is in Edit > Settings > Transfers > File Types > Default transfer type > Binary.

Timo Albert
  • 645
  • 1
  • 6
  • 17
teedyay
  • 23,293
  • 19
  • 66
  • 73
  • 7
    And maybe fill a bug report to filezilla. – Loïc Wolff Mar 13 '09 at 14:51
  • As for the bug report, I linked to the ticket. – mafu Jan 06 '13 at 13:03
  • 2
    Furthermore, Filezilla, while being a great program, is inconsistent in this regard... upon uploading my Win CRLF files to a unix server, the files will be automatically converted to just LF, upon downloading those same files from the same machines, no conversion happens. – James John McGuire 'Jahmic' Feb 07 '13 at 12:45
  • 6
    I don't understand the rationale behind having 'auto' as default. This will rewrite a lot of downloaded files, invalidating hashes. I would assume most people want their file unchanged by the transport. Functionality to rewrite is typically in the viewing or editor domain, not transport. My 2 cents. – krembanan Apr 25 '13 at 07:10
  • 1
    I used FileZilla for years before this bug surfaced on me. All of the sudden, it seemed, my php application was hosed with countless errors about an unexpected "{" on line 1. I had to switch FileZilla to Binary transfer mode to resolve the issue. Why did it take years for this to happen to me? I must have gone through the upload/download iteration several thousand times without an issue. – Sean Anderson Jul 25 '13 at 16:48
  • they said: https://wiki.filezilla-project.org/Data_Type I think filezilla don't care anything about this and the others. They do as they want. – vee Jul 09 '15 at 05:48
  • This happened to me too. I'm using version 3.13.1 and they didn't solve this bug yet!! The binary mode changing has worked for me. It seems they really don't care about this... – Fabiano Sep 08 '15 at 22:18
  • Yikes. This causes issues with diff and patching too. In Winmerge for example, I couldn't figure out how/why certain patch generations were seeing "every line changed" after generating the patch file. Although Winmerge itself has this setting, it doesn't apply to the patches. Ie, there is no setting in the Winmerge patch gen to "ignore end of line differences". Combine that with a non-refreshed local file open in editor which was opened before the Filezilla pull down, and there is 30 mins gone :D – dhaupin Dec 06 '16 at 16:43
  • This has started happening to me regardless of if binary is turned on. I do have a feeling a colleague of mine has it set to auto and is just saving the files like that *shakes fist*. I find I can get by following this guide http://stackoverflow.com/questions/12008986/sublime-text-2-how-to-delete-blank-empty-lines (if you have sublime text of course). – Thomas Harding Apr 27 '17 at 08:50
  • it doesn't work for .csv files.. i am still getting ^M at the end of each line when checked the csv in vi editor on putty. – LeMarque Nov 23 '17 at 06:28
  • the only difference between the free and pro versions is that the pro version has the default as binary. people are recommended to try upgrading to fix their issues and it usually works. happy customer. happy finance department. (joking ... maybe). – satnhak Sep 27 '20 at 19:21
6

What FTP transfer mode do you use (binary or ASCII?)? I'm not 100% sure, but I think if you force binary mode you should not have this problem.

GEOCHET
  • 21,119
  • 15
  • 74
  • 98
markus
  • 40,136
  • 23
  • 97
  • 142
5

The developers of FileZilla appear to have a pretty exclusive opinion on how unknown files should be transferred by default.

The bug report dwells since 2008. Of course, it may help if more people jump in and request a fix for this flaw.

dhaupin
  • 1,613
  • 2
  • 21
  • 24
mafu
  • 31,798
  • 42
  • 154
  • 247
  • It helps much more if more people jump in and post patches! And I do not see a relation between your answer and the question… – Shi Jan 05 '13 at 15:21
  • 1
    @Shi The relation is that the file being corrupted in the question was of unknown type, which should be transferred as-is instead of being converted. The latter is FZ's default setting and imo a definite bug, that's why I linked to the ticket. As for myself, I did offer to help weeks ago, even though I don't feel mandated to in any way, with no response of the developers yet. – mafu Jan 06 '13 at 13:02
  • @Shi +1 from me, answer links to an (the?) authoritative description of this problem IMHO (although perhaps this should have been a _comment_). – Sepster Jan 31 '13 at 04:54
3

The actual problem was with Filezilla FTP client default transfer mode, by default it is "Auto". Follow below step to convert it into "binary".

Go to the "Edit | Settings… "

enter image description here

In the new window, go to "transfers | File Types " and in "Default transfer type", select "Binary".

enter image description here

Purvik Dhorajiya
  • 4,662
  • 3
  • 34
  • 43