Uploading a file with ftplib

Michael_Goettsche michi.goettsche at gmx.de
Thu Jan 1 08:45:40 EST 2004


Hi all,

happy new year to all of you.

i'm trying to upload a file called "log.txt" with ftplib and tried the 
following:

Python 2.3.3 (#1, Dec 28 2003, 10:44:03)
[GCC 3.3.1 (SuSE Linux)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from ftplib import *
>>> ftp = FTP( "ftp.tuxipuxi.de" )
>>> ftp.login( "xxxxxx", "xxxxx" )
'230 Login successful.'
>>> #what now?

i've tried out different things for "what now",
for example:

ftp.storlines( "STOR log.txt", open( "log.txt", "r" ) )
fh = open( "log.txt", "r" )
ftp.storlines( "STOR log.txt", fh )
ftp.storbinary( "STOR log.txt", fh ) 

a file with size 0 is created on the server, but it's empty.
can anybody please tell me how to upload it properly?

thanks in advance,

regards,
Michael.






More information about the Python-list mailing list