December 13th, 2004, 11:22 AM
how can i upload an image file to my server using ftp?
December 13th, 2004, 11:51 AM
I'm not going to say rtfm http://www.python.org/doc/2.3.4/lib/module-ftplib.html
Since it's an image file you'll want to transfer in binary mode.
December 13th, 2004, 01:20 PM
i did rtfm but it is ****e. there is nothing about loogin into ftp servers with user name and password, nothing about putting a file on the server (well there mite be) and nothing about image files. it sucks ***.
December 13th, 2004, 03:58 PM
I've no idea what you were reading
And on the next page
And here is a simple sample:
That's all there is to it (without exception handling which you should consider in the design)
from ftplib import FTP
myftp = FTP("host url", "username", "password")
myftp.cwd("path_where_you_write_file") #if needed
myfile = open("myfilename",'rb') #binary :D
As a general solution, the areas likely to fail are:
FTP session cannot be created - bad parameters - no link etc
cwd fail - path doesnt exist, permission failure
storbinary fails - permission failure
file doenst exist, is corrupt, no read permission.
and general IP problems with bad links.
Bottom line - design the code to handle failure
Last edited by Grim Archon; December 14th, 2004 at 08:35 AM.
Reason: oops - binary mode for reading file