ftp upload with urllib or ftplib?

Samuel Siren samuel.siren at mailbox.swipnet.se
Sun Dec 9 06:13:14 CET 2001


This is my first posting to c.l.p.

It it possible to _upload_ a file using urllib? E.g. to post
the file contents, the username, and the password in the 'data',
or something?

Downloading an URL is done this way:

    contents = urllib.urlopen("http://x.com/f.html").read()


So, can I _upload_ (i.e. write) a file, using ftp, with
something like e.g.:

    status = urllib.urlopen("ftp://x.com/f.txt", [
                               username,
                               password,
                               open("t.txt","r").read()
                           ])


Or, do I need to use the "ftplib" module to _upload_ a file? In
that case, are there any good exemples on how to do that? I
looked at the ftplib documentation on the web page

    http://www.python.org/doc/current/lib/module-ftplib.html

but I didn't quite understand how to upload a file. (I'm no FTP
expert, BTW, my FTP experience is limited do uploading and
downloading files to my personal web page using FTP Voyager ...)


Regards,
/Samuel Sirén, Stockholm, Sweden - - - - - - - - - - - - - - - /




More information about the Python-list mailing list