ftplib question: how to upload files?

Jeremy Jones zanesdad at bellsouth.net
Thu Sep 11 15:45:50 EDT 2003


* python at sarcastic-horse.com (python at sarcastic-horse.com) wrote:
> Hi:
> 
> I want to write a procedure to automatically upload some files for me, but
> I'm getting stuck.  Before I write my own gruesome put() function, I
> wanted to check if there is an easier way.
> 
> Here's what I can do so far:
> >>>import ftplib
> >>>conn = ftplib.FTP('ftp.example.com')
> >>>conn.login(user='userid', passwd='passwd')
> >>>conn.cwd('/var/www/html/incoming')
> 
> What do I do to send files?
> 
> I have three files I want to upload, but I'm not sure what to do.  I hoped
> to find a ftplib.put() method, but it looks like ftplib is a low-level
> interface.


It is definitely a lower level interface.  You need to do something like:

conn.storbinary('STOR %s' % (file_name),file_object)
to put in binary mode or:

conn.storbinary('STOR %s' % (file_name),file_object)
to put in ascii mode.


HTH.

Jeremy Jones

> 
> All help is welcome.
> 
> 
> -- 
> http://mail.python.org/mailman/listinfo/python-list





More information about the Python-list mailing list