[thelist] ftp upload stuck problem

David Kaufman david at gigawatt.com
Tue Apr 3 11:26:34 CDT 2007

Hi Pieter,

Pieter Roosens <pieter at roosensdesign.com> wrote:
>>> To other servers I have no problem but here uploading with any ftp-
>>> program (on my Mac OSX) got stuck (freezes ..) but then the file is
>>> uploaded indeed.
>>> It seems that my system doesn't receive an "end" signal?
>>> The support guys tell me that it could be the connection ...?!
> ... I found some help file on their support pages which says to
> change all text files to upload as binary! That worked well with a
> test file!

Yes, you should upload all your files as binary, even "text" files.  The 
terms are misleading.  In the case of FTP transfers, "binary" mode 
means: Send the file exactly as it is, byte for byte.  This also means 
that the file's size when it gets to the server will be exactly the same 
as it is on your local machine.

FTP "text mode" actually means: while transferring this file, try to 
guess what the local line-ending conventions are for my operating 
system, and then try to guess what the line-ending conventions are for 
the server operating system, and change the contents of my file while 
transferring it from using local linefeeds to remote linefeeds.

In the case of "windows" text files (which use 2-byte CR+LF line 
endings) this means that when transferring a text file to a UNIX server, 
CR+LF character sequences would be replaced with just a LF, making a 500 
line file 500 bytes smaller once it reaches the server.  Macs on the 
other hand (thru OS 9) used a single CR as a line separator.  So Mac FTP 
programs tried to convert these CR's to LF's, but that an cause 
problems, too.

The problems that FTP text-mode attempted to solve are largely solved in 
modern software, and the use of text- or ASCII-transfer-mode now usually 
just introduces more problems of its own (as you've seen).  Macs and 
PC's have plenty of software that can create text files with UNIX 
linefeeds (nearly all HTML and code editors do that now) and, if that 
wasn't enough, most UNIX text-processing systems (most notably web 
servers, PHP and perl source code interpreters) have long been updated 
to tolerate PC and Mac linefeeds with no problems.

> ... But now I don't know if it's a good thing to upload "all"
> text files in binary. Normally it's wrong, right? I want to upload
> Joomla CMS there .. a bunch of php files ... Won't this harm Joomla?

Not just all text files... all files!  Seriously, turn of text mode 
completely (it was probably off to begin with by default, before 
*someone* turned it on...)  Do all of your FTP transfers in so-called 
binary mode.  Don't even think of them as "text" and "binary" mode --  
those names are misleading.  Think of text mode as: "screw-up-my-files 
mode"  and binary mode "delivery-my-files-correctly mode"! :-)

When using text mode, your ftp program was "hanging" because the server 
was not getting same file that was being sent.  When the server says 
"10,000 bytes received", and the size of the same file (with 100 lines 
of text) on the local machine is 10,000 + 100 bytes... some program got 
confused, believing that the transfer was complete, and was waiting for 
the server to finish, which it never did (because it already had).  If 
you transfer images in text mode they will be corrupted, too.  FrontPage 
didn't have this problem because it *always* transfers files unchanged, 
whether using HTTP or FTP (Microsoft products tend to lack any sort 
"text mode", because that would acknowledge that other (possibly better) 
text file formats even exist :-)

Hope this helps!


More information about the thelist mailing list