newbie question: ftp.storbinary()

Ayaz Ahmed Khan ayaz at dev.slash.null
Sat Feb 3 10:24:37 EST 2007


"Scott Ballard" typed:

> Sorry for the lame question, I'm still trying to pick up Python and new to 
> the list here.
> 
> Question:
> I'm trying to write a python script that will access an FTP site and upload 
> some files. I've gotten everything working except for the actual uploading 
> of the files.
> 
> I'm assuming that  I should use storbinary( command, file[, blocksize]) to 
> transfer the files. the documentation says "command should be an appropriate 
> "STOR" command: "STOR filename"."
> 
> I can't seem to figure out an `appropriate "STOR" command' is???

It frustrated the hell out of me too until I found this:

	http://effbot.org/librarybook/ftplib.htm

The following works:

	from ftplib import FTP
	ftp = FTP()
	ftp.set_debuglevel(2)
	ftp.connect(_host, _port)
	ftp.login(_user, _pass)
	ftp.storbinary('STOR ' + _file, open(_file))
	ftp.quit()

-- 
Ayaz Ahmed Khan

A witty saying proves nothing, but saying something pointless gets
people's attention.



More information about the Python-list mailing list