uploading a binary file with ftplib

Fredrik Lundh effbot at telia.com
Tue Mar 7 00:44:28 EST 2000


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)

</F>

<!-- (the eff-bot guide to) the standard python library:
http://www.pythonware.com/people/fredrik/librarybook.htm
-->





More information about the Python-list mailing list