My current python script:
import os
import ftplib
import hashlib
import glob
hashing = "123"
m = hashlib.md5()
m.update(hashing)
dd = m.hexdigest()
ftp = ftplib.FTP('localhost','kevin403','S$ip1234')
ftp.cwd('/var/www/html/image')
for image in glob.glob(os.path.join('Desktop/images/test*.png')):
with open(image, 'rb') as file:
ftp.storbinary('STOR '+dd+ '.png', file)
ftp.close()
ftp.quit()
Anybody know this error? I trying to send file over to another folder via ftp.
The error i got when running the script:
Traceback (most recent call last):
File "/home/kevin403/wwq.py", line 21, in <module>
ftp.quit()
File "/usr/lib/python2.7/ftplib.py", line 591, in quit
resp = self.voidcmd('QUIT')
File "/usr/lib/python2.7/ftplib.py", line 253, in voidcmd
self.putcmd(cmd)
File "/usr/lib/python2.7/ftplib.py", line 181, in putcmd
self.putline(line)
File "/usr/lib/python2.7/ftplib.py", line 176, in putline
self.sock.sendall(line)
AttributeError: 'NoneType' object has no attribute 'sendall'
Just erase
ftp.close()
, sinceftp.quit()
implies call.close()
function you're telling to close two times, and then quit falls because socket was already closed.FTPlib Documentation