uploading a binary file with ftplib

Sjoerd Mullender sjoerd at oratrix.nl
Tue Mar 7 15:49:38 CET 2000

On Tue, Mar 7 2000 "Fredrik Lundh" wrote:

> thehaas at my-deja.com wrote:
> > I've submitted this to python.faqts.com, but no one has answered.  So
> > I'm asking it here. . .
> >
> > I'm trying to upload a binary file to a site using ftplib.  I can log in
> > successfully and do "cd dir_name", but cannot figure out how to upload
> > the file.  The standard Python module documentation seems a bit cryptic
> > to me in this case (though it is usually quite good).
> well, the docs clearly tell you to pass a file object as the
> second argument, not a string.  so does the doc string...
> > ftp.storbinary('stor ravine.pyc',open('ravine.pyc','r').read(),2)
> ftp.storbinary('stor ravine.pyc', open('ravine.pyc','r'), 1024)

Shouldn't that be ...open('ravine.pyc','rb')...
(note the b).
We are talking uploading a *binary* file here...

-- Sjoerd Mullender <sjoerd.mullender at oratrix.com>

More information about the Python-list mailing list