Uploading a file with ftplib

Discussion in 'Python' started by Michael_Goettsche, Jan 1, 2004.

  1. 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.
     
    Michael_Goettsche, Jan 1, 2004
    #1
    1. Advertising

  2. Michael_Goettsche

    Rene Pijlman Guest

    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()

    --
    René Pijlman
     
    Rene Pijlman, Jan 1, 2004
    #2
    1. Advertising

  3. On Thursday 01 January 2004 15:14, Rene Pijlman wrote:
    > 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()
    >
    > --
    > René Pijlman


    thank you, works perfect.

    regards,
    Michael.
     
    Michael_Goettsche, Jan 1, 2004
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Dung Ping
    Replies:
    10
    Views:
    992
    Chaddy2222
    Jan 16, 2006
  2. Joshua Burvill

    Sending file to print server using ftplib

    Joshua Burvill, May 20, 2004, in forum: Python
    Replies:
    0
    Views:
    322
    Joshua Burvill
    May 20, 2004
  3. rbt
    Replies:
    2
    Views:
    276
  4. Peter A. Schott
    Replies:
    0
    Views:
    896
    Peter A. Schott
    Feb 10, 2005
  5. Sky Larking
    Replies:
    4
    Views:
    622
    Sky Larking
    Feb 25, 2010
Loading...

Share This Page