Hello, I am trying to upload a PDF using Python to an outside FTP server. However, I keep getting the error about concatenating string and and file objects.
CODE:
import ftplib
# Logging into ftp site with login information
session = ftplib.FTP("host","username","password")
print('Logging in')
# Choosing file to send
filename = "TEST12142020.pdf"
filepath = open(r'G:\\GIS\\filepath\\TEST12142020.pdf', 'rb')
print ('Opened file')
# Sending the file
print('Sending file')
session.storbinary('STOR ' + filepath, filename)
print('Sent file')
# Closing file and ftp
file.close()
print('Closing file')
session.quit()
ERROR:
Logging in
Opened file
Sending file
Traceback (most recent call last):
File "G:\pathname\UploadtoFTPTest.py", line 14, in <module>
session.storbinary('STOR ' + filepath, filename)
TypeError: cannot concatenate 'str' and 'file' objects