Uploading a file with ftplib

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Michael_Goettsche

    Uploading a file with ftplib

    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.[color=blue][color=green][color=darkred]
    >>> from ftplib import *
    >>> ftp = FTP( "ftp.tuxipuxi.d e" )
    >>> ftp.login( "xxxxxx", "xxxxx" )[/color][/color][/color]
    '230 Login successful.'[color=blue][color=green][color=darkred]
    >>> #what now?[/color][/color][/color]

    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.



  • Rene Pijlman

    #2
    Re: Uploading a file with ftplib

    Michael_Goettsc he:[color=blue]
    >can anybody please tell me how to upload it properly?[/color]

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

    ftp = ftplib.FTP(Host name,Username,P assword)
    ftp.cwd(Working Directory)
    ftp.storbinary( "STOR " + RemoteZipFile, file(LocalZipFi le, "rb"))
    ftp.quit()

    --
    René Pijlman

    Comment

    • Michael_Goettsche

      #3
      Re: Uploading a file with ftplib

      On Thursday 01 January 2004 15:14, Rene Pijlman wrote:[color=blue]
      > Michael_Goettsc he:[color=green]
      > >can anybody please tell me how to upload it properly?[/color]
      >
      > This is a snippet from one of my scripts, that works fine:
      >
      > ftp = ftplib.FTP(Host name,Username,P assword)
      > ftp.cwd(Working Directory)
      > ftp.storbinary( "STOR " + RemoteZipFile, file(LocalZipFi le, "rb"))
      > ftp.quit()
      >
      > --
      > René Pijlman[/color]

      thank you, works perfect.

      regards,
      Michael.


      Comment

      Working...