Uploading a file with ftplib

  • Thread starter Michael_Goettsche
  • Start date
M

Michael_Goettsche

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.
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.
 
R

Rene Pijlman

Michael_Goettsche:
can anybody please tell me how to upload it properly?

This is a snippet from one of my scripts, that works fine:

ftp = ftplib.FTP(Hostname,Username,Password)
ftp.cwd(WorkingDirectory)
ftp.storbinary("STOR " + RemoteZipFile, file(LocalZipFile, "rb"))
ftp.quit()
 
M

Michael_Goettsche

Michael_Goettsche:

This is a snippet from one of my scripts, that works fine:

ftp = ftplib.FTP(Hostname,Username,Password)
ftp.cwd(WorkingDirectory)
ftp.storbinary("STOR " + RemoteZipFile, file(LocalZipFile, "rb"))
ftp.quit()

thank you, works perfect.

regards,
Michael.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top