Ah, my bad. You are right. I changed it to this:
filepath = r'G:\GIS\Departments\ItmdGis\Users\hbubac\Data and Scripts\Crime Maps\new scripts'
file_object = open(r'G:\GIS\Departments\ItmdGis\Users\hbubac\Data and Scripts\Crime Maps\new scripts\TEST12142020.pdf', 'rb')
print ('Opened file')
# Sending the file
print('Sending file')
session.storbinary('STOR ' + filepath, file_object)
print('Sent file')
And still got this for an error:
Logging in
Opened file
Sending file
Traceback (most recent call last):
File "G:\GIS\Departments\ItmdGis\Users\hbubac\Data and Scripts\Crime Maps\new scripts\UploadtoFTPTest.py", line 14, in <module>
session.storbinary('STOR ' + filepath, file_object)
File "C:\Python27\ArcGIS10.5\lib\ftplib.py", line 471, in storbinary
conn = self.transfercmd(cmd, rest)
File "C:\Python27\ArcGIS10.5\lib\ftplib.py", line 376, in transfercmd
return self.ntransfercmd(cmd, rest)[0]
File "C:\Python27\ArcGIS10.5\lib\ftplib.py", line 339, in ntransfercmd
resp = self.sendcmd(cmd)
File "C:\Python27\ArcGIS10.5\lib\ftplib.py", line 249, in sendcmd
return self.getresp()
File "C:\Python27\ArcGIS10.5\lib\ftplib.py", line 224, in getresp
raise error_perm, resp
ftplib.error_perm: 553 Prohibited file name: G:\GIS\Departments\ItmdGis\Users\hbubac\Data and Scripts\Crime Maps\new scripts