<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Uploading PDF through FTP using Python in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/uploading-pdf-through-ftp-using-python/m-p/1033064#M60208</link>
    <description>&lt;P&gt;The "filename" is the name you want on the FTP Server, not the name of the file on the local machine.&amp;nbsp; The local file is already addressed through the file object being passed to the command.&lt;/P&gt;</description>
    <pubDate>Thu, 04 Mar 2021 19:56:35 GMT</pubDate>
    <dc:creator>JoshuaBixby</dc:creator>
    <dc:date>2021-03-04T19:56:35Z</dc:date>
    <item>
      <title>Uploading PDF through FTP using Python</title>
      <link>https://community.esri.com/t5/python-questions/uploading-pdf-through-ftp-using-python/m-p/1032939#M60192</link>
      <description>&lt;P&gt;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.&lt;/P&gt;&lt;P&gt;CODE:&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; import ftplib&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; # Logging into ftp site with login information&lt;BR /&gt;&amp;nbsp; &amp;nbsp; session = ftplib.FTP("host","username","password")&lt;BR /&gt;&amp;nbsp; &amp;nbsp; print('Logging in')&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; # Choosing file to send&lt;BR /&gt;&amp;nbsp; &amp;nbsp; filename = "TEST12142020.pdf"&lt;BR /&gt;&amp;nbsp; &amp;nbsp; filepath = open(r'G:\\GIS\\filepath\\TEST12142020.pdf', 'rb')&lt;BR /&gt;&amp;nbsp; &amp;nbsp; print ('Opened file')&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; # Sending the file&lt;BR /&gt;&amp;nbsp; &amp;nbsp; print('Sending file')&lt;BR /&gt;&amp;nbsp; &amp;nbsp; session.storbinary('STOR ' + filepath, filename)&lt;BR /&gt;&amp;nbsp; &amp;nbsp; print('Sent file')&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; # Closing file and ftp&lt;BR /&gt;&amp;nbsp; &amp;nbsp; file.close()&lt;BR /&gt;&amp;nbsp; &amp;nbsp; print('Closing file')&lt;BR /&gt;&amp;nbsp; &amp;nbsp; session.quit()&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;ERROR:&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; Logging in&lt;BR /&gt;&amp;nbsp; &amp;nbsp; Opened file&lt;BR /&gt;&amp;nbsp; &amp;nbsp; Sending file&lt;BR /&gt;&amp;nbsp; &amp;nbsp; Traceback (most recent call last):&lt;BR /&gt;&amp;nbsp; &amp;nbsp; File "G:\pathname\UploadtoFTPTest.py", line 14, in &amp;lt;module&amp;gt;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; session.storbinary('STOR ' + filepath, filename)&lt;BR /&gt;&amp;nbsp; &amp;nbsp; TypeError: cannot concatenate 'str' and 'file' objects&lt;/P&gt;</description>
      <pubDate>Thu, 04 Mar 2021 16:53:24 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/uploading-pdf-through-ftp-using-python/m-p/1032939#M60192</guid>
      <dc:creator>Bubacz_Hannah</dc:creator>
      <dc:date>2021-03-04T16:53:24Z</dc:date>
    </item>
    <item>
      <title>Re: Uploading PDF through FTP using Python</title>
      <link>https://community.esri.com/t5/python-questions/uploading-pdf-through-ftp-using-python/m-p/1032948#M60193</link>
      <description>&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;filepath = open(r'G:\\GIS\\filepath\\TEST12142020.pdf', 'rb')&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;You made this a file object.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Did you mean&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;filepath = r'G:\\GIS\\filepath'&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;and the previous to be something like&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;file_object = open(r'G:\\GIS\\filepath\\TEST12142020.pdf', 'rb')&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Then decide what actually needs to go in here&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;session.storbinary('STOR ' + ???, ????)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 04 Mar 2021 17:10:51 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/uploading-pdf-through-ftp-using-python/m-p/1032948#M60193</guid>
      <dc:creator>DanPatterson</dc:creator>
      <dc:date>2021-03-04T17:10:51Z</dc:date>
    </item>
    <item>
      <title>Re: Uploading PDF through FTP using Python</title>
      <link>https://community.esri.com/t5/python-questions/uploading-pdf-through-ftp-using-python/m-p/1032956#M60194</link>
      <description>&lt;P&gt;Hey Dan, so like this? I get the same error.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;filepath = r'G:\\GIS\\filepath'&lt;BR /&gt;file_object = open(r'G:\\GIS\\filepath\\TEST12142020.pdf', 'rb')&lt;BR /&gt;print ('Opened file')&lt;/P&gt;&lt;P&gt;# Sending the file&lt;BR /&gt;print('Sending file')&lt;BR /&gt;session.storbinary('STOR ' + file_object, filepath)&lt;BR /&gt;print('Sent file')&lt;/P&gt;</description>
      <pubDate>Thu, 04 Mar 2021 17:17:55 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/uploading-pdf-through-ftp-using-python/m-p/1032956#M60194</guid>
      <dc:creator>Bubacz_Hannah</dc:creator>
      <dc:date>2021-03-04T17:17:55Z</dc:date>
    </item>
    <item>
      <title>Re: Uploading PDF through FTP using Python</title>
      <link>https://community.esri.com/t5/python-questions/uploading-pdf-through-ftp-using-python/m-p/1032957#M60195</link>
      <description>&lt;P&gt;I also get the same error doing this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;# Choosing file to send&lt;BR /&gt;filename = open(r'G:\\GIS\\filepath\\TEST12142020.pdf', 'rb')&lt;BR /&gt;print ('Opened file')&lt;/P&gt;&lt;P&gt;# Sending the file&lt;BR /&gt;print('Sending file')&lt;BR /&gt;session.storbinary('STOR ' + filename)&lt;BR /&gt;print('Sent file')&lt;/P&gt;</description>
      <pubDate>Thu, 04 Mar 2021 17:19:19 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/uploading-pdf-through-ftp-using-python/m-p/1032957#M60195</guid>
      <dc:creator>Bubacz_Hannah</dc:creator>
      <dc:date>2021-03-04T17:19:19Z</dc:date>
    </item>
    <item>
      <title>Re: Uploading PDF through FTP using Python</title>
      <link>https://community.esri.com/t5/python-questions/uploading-pdf-through-ftp-using-python/m-p/1032986#M60196</link>
      <description>&lt;P&gt;As the error says, you cannot concatenate&amp;nbsp;'str' and 'file' objects. You'd have to do something like&lt;/P&gt;&lt;LI-CODE lang="python"&gt;filepath = r'G:\\GIS\\filepath'
file_object = open(r'G:\\GIS\\filepath\\TEST12142020.pdf', 'rb')
print ('Opened file')

# Sending the file
print('Sending file')
session.storbinary('STOR ' + filepath, file_object)
print('Sent file')&lt;/LI-CODE&gt;</description>
      <pubDate>Thu, 04 Mar 2021 18:28:34 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/uploading-pdf-through-ftp-using-python/m-p/1032986#M60196</guid>
      <dc:creator>BlakeTerhune</dc:creator>
      <dc:date>2021-03-04T18:28:34Z</dc:date>
    </item>
    <item>
      <title>Re: Uploading PDF through FTP using Python</title>
      <link>https://community.esri.com/t5/python-questions/uploading-pdf-through-ftp-using-python/m-p/1032999#M60197</link>
      <description>&lt;P&gt;Ah, I didn't realize that filepath and file_object were actualy variable names that it would recognize, not just what I chose to call it. I am running the code through Notepad++ with Run on Python27 and got these errors:&lt;/P&gt;&lt;P&gt;Logging in&lt;BR /&gt;Opened file&lt;BR /&gt;Sending file&lt;BR /&gt;Traceback (most recent call last):&lt;BR /&gt;File "G:\GIS\Departments\ItmdGis\Users\hbubac\Data and Scripts\Crime Maps\new scripts\UploadtoFTPTest.py", line 14, in &amp;lt;module&amp;gt;&lt;BR /&gt;session.storbinary('STOR ' + filepath, file_object)&lt;BR /&gt;File "C:\Python27\ArcGIS10.5\lib\ftplib.py", line 471, in storbinary&lt;BR /&gt;conn = self.transfercmd(cmd, rest)&lt;BR /&gt;File "C:\Python27\ArcGIS10.5\lib\ftplib.py", line 376, in transfercmd&lt;BR /&gt;return self.ntransfercmd(cmd, rest)[0]&lt;BR /&gt;File "C:\Python27\ArcGIS10.5\lib\ftplib.py", line 339, in ntransfercmd&lt;BR /&gt;resp = self.sendcmd(cmd)&lt;BR /&gt;File "C:\Python27\ArcGIS10.5\lib\ftplib.py", line 249, in sendcmd&lt;BR /&gt;return self.getresp()&lt;BR /&gt;File "C:\Python27\ArcGIS10.5\lib\ftplib.py", line 224, in getresp&lt;BR /&gt;raise error_perm, resp&lt;BR /&gt;ftplib.error_perm: 553 Prohibited file name: G:\\GIS\\Departments\\ItmdGis\\Users\\hbubac\\Data and Scripts\\Crime Maps\\new scripts&lt;/P&gt;</description>
      <pubDate>Thu, 04 Mar 2021 18:54:49 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/uploading-pdf-through-ftp-using-python/m-p/1032999#M60197</guid>
      <dc:creator>Bubacz_Hannah</dc:creator>
      <dc:date>2021-03-04T18:54:49Z</dc:date>
    </item>
    <item>
      <title>Re: Uploading PDF through FTP using Python</title>
      <link>https://community.esri.com/t5/python-questions/uploading-pdf-through-ftp-using-python/m-p/1033002#M60198</link>
      <description>&lt;P&gt;You formatted the file path a a raw string but then included the escape backslash. You have to do one or the other. I recommend just using the raw string with single backslashes.&lt;/P&gt;&lt;LI-CODE lang="python"&gt;filepath = r'G:\GIS\filepath'
file_object = open(r'G:\GIS\\filepath\TEST12142020.pdf', 'rb')
print ('Opened file')

# Sending the file
print('Sending file')
session.storbinary('STOR ' + filepath, file_object)
print('Sent file')&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 04 Mar 2021 18:57:13 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/uploading-pdf-through-ftp-using-python/m-p/1033002#M60198</guid>
      <dc:creator>BlakeTerhune</dc:creator>
      <dc:date>2021-03-04T18:57:13Z</dc:date>
    </item>
    <item>
      <title>Re: Uploading PDF through FTP using Python</title>
      <link>https://community.esri.com/t5/python-questions/uploading-pdf-through-ftp-using-python/m-p/1033005#M60199</link>
      <description>&lt;P&gt;Ah, my bad. You are right. I changed it to this:&lt;/P&gt;&lt;P&gt;filepath = r'G:\GIS\Departments\ItmdGis\Users\hbubac\Data and Scripts\Crime Maps\new scripts'&lt;BR /&gt;file_object = open(r'G:\GIS\Departments\ItmdGis\Users\hbubac\Data and Scripts\Crime Maps\new scripts\TEST12142020.pdf', 'rb')&lt;BR /&gt;print ('Opened file')&lt;/P&gt;&lt;P&gt;# Sending the file&lt;BR /&gt;print('Sending file')&lt;BR /&gt;session.storbinary('STOR ' + filepath, file_object)&lt;BR /&gt;print('Sent file')&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And still got this for an error:&lt;/P&gt;&lt;P&gt;Logging in&lt;BR /&gt;Opened file&lt;BR /&gt;Sending file&lt;BR /&gt;Traceback (most recent call last):&lt;BR /&gt;File "G:\GIS\Departments\ItmdGis\Users\hbubac\Data and Scripts\Crime Maps\new scripts\UploadtoFTPTest.py", line 14, in &amp;lt;module&amp;gt;&lt;BR /&gt;session.storbinary('STOR ' + filepath, file_object)&lt;BR /&gt;File "C:\Python27\ArcGIS10.5\lib\ftplib.py", line 471, in storbinary&lt;BR /&gt;conn = self.transfercmd(cmd, rest)&lt;BR /&gt;File "C:\Python27\ArcGIS10.5\lib\ftplib.py", line 376, in transfercmd&lt;BR /&gt;return self.ntransfercmd(cmd, rest)[0]&lt;BR /&gt;File "C:\Python27\ArcGIS10.5\lib\ftplib.py", line 339, in ntransfercmd&lt;BR /&gt;resp = self.sendcmd(cmd)&lt;BR /&gt;File "C:\Python27\ArcGIS10.5\lib\ftplib.py", line 249, in sendcmd&lt;BR /&gt;return self.getresp()&lt;BR /&gt;File "C:\Python27\ArcGIS10.5\lib\ftplib.py", line 224, in getresp&lt;BR /&gt;raise error_perm, resp&lt;BR /&gt;ftplib.error_perm: 553 Prohibited file name: G:\GIS\Departments\ItmdGis\Users\hbubac\Data and Scripts\Crime Maps\new scripts&lt;/P&gt;</description>
      <pubDate>Thu, 04 Mar 2021 19:00:15 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/uploading-pdf-through-ftp-using-python/m-p/1033005#M60199</guid>
      <dc:creator>Bubacz_Hannah</dc:creator>
      <dc:date>2021-03-04T19:00:15Z</dc:date>
    </item>
    <item>
      <title>Re: Uploading PDF through FTP using Python</title>
      <link>https://community.esri.com/t5/python-questions/uploading-pdf-through-ftp-using-python/m-p/1033016#M60200</link>
      <description>&lt;P&gt;The command input needs to be a path to the file, not a folder. Try&lt;/P&gt;&lt;LI-CODE lang="python"&gt;filepath = r'G:\GIS\filepath\TEST12142020.pdf'
file_object = open(filepath, 'rb')
print ('Opened file')

# Sending the file
print('Sending file')
session.storbinary('STOR ' + filepath, file_object)
print('Sent file')&lt;/LI-CODE&gt;</description>
      <pubDate>Thu, 04 Mar 2021 19:06:34 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/uploading-pdf-through-ftp-using-python/m-p/1033016#M60200</guid>
      <dc:creator>BlakeTerhune</dc:creator>
      <dc:date>2021-03-04T19:06:34Z</dc:date>
    </item>
    <item>
      <title>Re: Uploading PDF through FTP using Python</title>
      <link>https://community.esri.com/t5/python-questions/uploading-pdf-through-ftp-using-python/m-p/1033025#M60202</link>
      <description>&lt;P&gt;Hmmm, looks like the same error. Maybe I need to run it some way different than Python 27? Or my Python version is getting mixed up because I have both ArcMap and ArcPro installed on my computer?&lt;/P&gt;&lt;P&gt;CODE:&lt;/P&gt;&lt;P&gt;# Choosing file to send&lt;BR /&gt;filepath = r'G:\GIS\filepath\TEST12142020.pdf'&lt;BR /&gt;file_object = open(filepath, 'rb')&lt;BR /&gt;print ('Opened file')&lt;/P&gt;&lt;P&gt;# Sending the file&lt;BR /&gt;print('Sending file')&lt;BR /&gt;session.storbinary('STOR ' + filepath, file_object)&lt;BR /&gt;print('Sent file')&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;ERROR:&lt;/P&gt;&lt;P&gt;Logging in&lt;BR /&gt;Opened file&lt;BR /&gt;Sending file&lt;BR /&gt;Traceback (most recent call last):&lt;BR /&gt;File "G:\GIS\Departments\ItmdGis\Users\hbubac\Data and Scripts\Crime Maps\new scripts\UploadtoFTPTest.py", line 14, in &amp;lt;module&amp;gt;&lt;BR /&gt;session.storbinary('STOR ' + filepath, file_object)&lt;BR /&gt;File "C:\Python27\ArcGIS10.5\lib\ftplib.py", line 471, in storbinary&lt;BR /&gt;conn = self.transfercmd(cmd, rest)&lt;BR /&gt;File "C:\Python27\ArcGIS10.5\lib\ftplib.py", line 376, in transfercmd&lt;BR /&gt;return self.ntransfercmd(cmd, rest)[0]&lt;BR /&gt;File "C:\Python27\ArcGIS10.5\lib\ftplib.py", line 339, in ntransfercmd&lt;BR /&gt;resp = self.sendcmd(cmd)&lt;BR /&gt;File "C:\Python27\ArcGIS10.5\lib\ftplib.py", line 249, in sendcmd&lt;BR /&gt;return self.getresp()&lt;BR /&gt;File "C:\Python27\ArcGIS10.5\lib\ftplib.py", line 224, in getresp&lt;BR /&gt;raise error_perm, resp&lt;BR /&gt;ftplib.error_perm: 553 Prohibited file name: G:\GIS\Departments\ItmdGis\Users\hbubac\Data and Scripts\Crime Maps\new scripts\TEST12142020.pdf&lt;/P&gt;</description>
      <pubDate>Thu, 04 Mar 2021 19:10:35 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/uploading-pdf-through-ftp-using-python/m-p/1033025#M60202</guid>
      <dc:creator>Bubacz_Hannah</dc:creator>
      <dc:date>2021-03-04T19:10:35Z</dc:date>
    </item>
    <item>
      <title>Re: Uploading PDF through FTP using Python</title>
      <link>https://community.esri.com/t5/python-questions/uploading-pdf-through-ftp-using-python/m-p/1033028#M60203</link>
      <description>&lt;P&gt;Try putting the file in a simpler directory, like C:\temp\TEST12142020.pdf&lt;/P&gt;</description>
      <pubDate>Thu, 04 Mar 2021 19:12:27 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/uploading-pdf-through-ftp-using-python/m-p/1033028#M60203</guid>
      <dc:creator>BlakeTerhune</dc:creator>
      <dc:date>2021-03-04T19:12:27Z</dc:date>
    </item>
    <item>
      <title>Re: Uploading PDF through FTP using Python</title>
      <link>https://community.esri.com/t5/python-questions/uploading-pdf-through-ftp-using-python/m-p/1033032#M60204</link>
      <description>&lt;P&gt;CODE:&lt;/P&gt;&lt;P&gt;# Choosing file to send&lt;BR /&gt;filepath = r'C:\temp\TEST12142020.pdf'&lt;BR /&gt;file_object = open(filepath, 'rb')&lt;BR /&gt;print ('Opened file')&lt;/P&gt;&lt;P&gt;# Sending the file&lt;BR /&gt;print('Sending file')&lt;BR /&gt;session.storbinary('STOR ' + filepath, file_object)&lt;BR /&gt;print('Sent file')&lt;/P&gt;&lt;P&gt;ERROR:&lt;/P&gt;&lt;P&gt;Logging in&lt;BR /&gt;Opened file&lt;BR /&gt;Sending file&lt;BR /&gt;Traceback (most recent call last):&lt;BR /&gt;File "C:\temp\UploadtoFTPTest.py", line 14, in &amp;lt;module&amp;gt;&lt;BR /&gt;session.storbinary('STOR ' + filepath, file_object)&lt;BR /&gt;File "C:\Python27\ArcGIS10.5\lib\ftplib.py", line 471, in storbinary&lt;BR /&gt;conn = self.transfercmd(cmd, rest)&lt;BR /&gt;File "C:\Python27\ArcGIS10.5\lib\ftplib.py", line 376, in transfercmd&lt;BR /&gt;return self.ntransfercmd(cmd, rest)[0]&lt;BR /&gt;File "C:\Python27\ArcGIS10.5\lib\ftplib.py", line 339, in ntransfercmd&lt;BR /&gt;resp = self.sendcmd(cmd)&lt;BR /&gt;File "C:\Python27\ArcGIS10.5\lib\ftplib.py", line 249, in sendcmd&lt;BR /&gt;return self.getresp()&lt;BR /&gt;File "C:\Python27\ArcGIS10.5\lib\ftplib.py", line 224, in getresp&lt;BR /&gt;raise error_perm, resp&lt;BR /&gt;ftplib.error_perm: 553 Prohibited file name: C:\temp\TEST12142020.pdf&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 04 Mar 2021 19:17:27 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/uploading-pdf-through-ftp-using-python/m-p/1033032#M60204</guid>
      <dc:creator>Bubacz_Hannah</dc:creator>
      <dc:date>2021-03-04T19:17:27Z</dc:date>
    </item>
    <item>
      <title>Re: Uploading PDF through FTP using Python</title>
      <link>https://community.esri.com/t5/python-questions/uploading-pdf-through-ftp-using-python/m-p/1033059#M60207</link>
      <description>&lt;P&gt;According to &lt;A href="https://stackoverflow.com/a/39448193" target="_self"&gt;this&lt;/A&gt;, try just using the file name in the command.&lt;/P&gt;&lt;LI-CODE lang="python"&gt;# Choosing file to send
filename = 'TEST12142020.pdf'
filepath = r'C:\temp\{}'.format(filename)
file_object = open(filepath, 'rb')
print ('Opened file')

# Sending the file
print('Sending file')
session.storbinary('STOR ' + filename, file_object)
print('Sent file')&lt;/LI-CODE&gt;</description>
      <pubDate>Thu, 04 Mar 2021 19:48:01 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/uploading-pdf-through-ftp-using-python/m-p/1033059#M60207</guid>
      <dc:creator>BlakeTerhune</dc:creator>
      <dc:date>2021-03-04T19:48:01Z</dc:date>
    </item>
    <item>
      <title>Re: Uploading PDF through FTP using Python</title>
      <link>https://community.esri.com/t5/python-questions/uploading-pdf-through-ftp-using-python/m-p/1033064#M60208</link>
      <description>&lt;P&gt;The "filename" is the name you want on the FTP Server, not the name of the file on the local machine.&amp;nbsp; The local file is already addressed through the file object being passed to the command.&lt;/P&gt;</description>
      <pubDate>Thu, 04 Mar 2021 19:56:35 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/uploading-pdf-through-ftp-using-python/m-p/1033064#M60208</guid>
      <dc:creator>JoshuaBixby</dc:creator>
      <dc:date>2021-03-04T19:56:35Z</dc:date>
    </item>
    <item>
      <title>Re: Uploading PDF through FTP using Python</title>
      <link>https://community.esri.com/t5/python-questions/uploading-pdf-through-ftp-using-python/m-p/1033074#M60209</link>
      <description>&lt;P&gt;That worked! Perfect, thank you. I still have some finagling but this is definitely one step closer. If you don't mind, one more question. It uploaded the file but then I got an error about my closing of the file. I tried closing filepath, file_object, and filename and all got the error saying it received a string.&lt;/P&gt;&lt;P&gt;# Choosing file to send&lt;BR /&gt;filename = 'TEST12142020.pdf'&lt;BR /&gt;filepath = r'C:\temp\{}'.format(filename)&lt;BR /&gt;file_object = open(filepath, 'rb')&lt;BR /&gt;print ('Opened file')&lt;/P&gt;&lt;P&gt;# Sending the file&lt;BR /&gt;print('Sending file')&lt;BR /&gt;session.storbinary('STOR ' + filename, file_object)&lt;BR /&gt;print('Sent file')&lt;/P&gt;&lt;P&gt;# Closing file and ftp&lt;BR /&gt;file.close(filepath)&lt;BR /&gt;print('Closing file')&lt;BR /&gt;session.quit()&lt;/P&gt;&lt;P&gt;ERROR:&lt;/P&gt;&lt;P&gt;Logging in&lt;BR /&gt;Opened file&lt;BR /&gt;Sending file&lt;BR /&gt;Sent file&lt;BR /&gt;Traceback (most recent call last):&lt;BR /&gt;File "C:\temp\UploadtoFTPTest.py", line 19, in &amp;lt;module&amp;gt;&lt;BR /&gt;file.close(filepath)&lt;BR /&gt;TypeError: descriptor 'close' requires a 'file' object but received a 'str'&lt;/P&gt;</description>
      <pubDate>Thu, 04 Mar 2021 20:21:14 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/uploading-pdf-through-ftp-using-python/m-p/1033074#M60209</guid>
      <dc:creator>Bubacz_Hannah</dc:creator>
      <dc:date>2021-03-04T20:21:14Z</dc:date>
    </item>
    <item>
      <title>Re: Uploading PDF through FTP using Python</title>
      <link>https://community.esri.com/t5/python-questions/uploading-pdf-through-ftp-using-python/m-p/1033096#M60212</link>
      <description>&lt;P&gt;Don't pass anything as an argument. Just do&amp;nbsp;&lt;FONT face="courier new,courier"&gt;file_object.close()&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;However, a better way would be to use the with keyword to open and automatically close the file. Otherwise, you should be using a try/except/finally with open/close.&lt;/P&gt;&lt;LI-CODE lang="python"&gt;# define ftp session out here
try:
    # Choosing file to send
    filename = 'TEST12142020.pdf'
    filepath = r'C:\temp\{}'.format(filename)
    with open(filepath, 'rb') as file:
        print ('Opened file')

        # Sending the file
        print('Sending file')
        session.storbinary('STOR ' + filename, file)
        print('Sent file')

finally:
    session.quit()&lt;/LI-CODE&gt;</description>
      <pubDate>Thu, 04 Mar 2021 21:00:32 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/uploading-pdf-through-ftp-using-python/m-p/1033096#M60212</guid>
      <dc:creator>BlakeTerhune</dc:creator>
      <dc:date>2021-03-04T21:00:32Z</dc:date>
    </item>
    <item>
      <title>Re: Uploading PDF through FTP using Python</title>
      <link>https://community.esri.com/t5/python-questions/uploading-pdf-through-ftp-using-python/m-p/1033099#M60213</link>
      <description>&lt;P&gt;Perfect. Thank you so much for all your help.&lt;/P&gt;</description>
      <pubDate>Thu, 04 Mar 2021 21:03:28 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/uploading-pdf-through-ftp-using-python/m-p/1033099#M60213</guid>
      <dc:creator>Bubacz_Hannah</dc:creator>
      <dc:date>2021-03-04T21:03:28Z</dc:date>
    </item>
    <item>
      <title>Re: Uploading PDF through FTP using Python</title>
      <link>https://community.esri.com/t5/python-questions/uploading-pdf-through-ftp-using-python/m-p/1034453#M60309</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;Could you help me with one more thing? I need to put it in a certain folder within the ftp site but cannot figure out the code. Thoughts? Thanks!&lt;/P&gt;&lt;P&gt;The folder I need it in:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Bubacz_Hannah_0-1615300876257.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/7941iAEF35F14850C07E9/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Bubacz_Hannah_0-1615300876257.png" alt="Bubacz_Hannah_0-1615300876257.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;CODE:&lt;/P&gt;&lt;P&gt;# Sending the file&lt;BR /&gt;print('Sending file')&lt;BR /&gt;session.storbinary('STOR {/srv/ftp/pub/gis/crimemaps}' + filename, file_object)&lt;BR /&gt;print('Sent file')&lt;/P&gt;&lt;P&gt;ERROR:&lt;/P&gt;&lt;P&gt;&amp;lt;module&amp;gt;&lt;BR /&gt;session.storbinary('STOR {ftp.milwaukee.gov/srv/ftp/pub/gis/crimemaps}' + filename, file_object)&lt;BR /&gt;File "C:\Python27\ArcGIS10.5\lib\ftplib.py", line 471, in storbinary&lt;BR /&gt;conn = self.transfercmd(cmd, rest)&lt;BR /&gt;File "C:\Python27\ArcGIS10.5\lib\ftplib.py", line 376, in transfercmd&lt;BR /&gt;return self.ntransfercmd(cmd, rest)[0]&lt;BR /&gt;File "C:\Python27\ArcGIS10.5\lib\ftplib.py", line 339, in ntransfercmd&lt;BR /&gt;resp = self.sendcmd(cmd)&lt;BR /&gt;File "C:\Python27\ArcGIS10.5\lib\ftplib.py", line 249, in sendcmd&lt;BR /&gt;return self.getresp()&lt;BR /&gt;File "C:\Python27\ArcGIS10.5\lib\ftplib.py", line 224, in getresp&lt;BR /&gt;raise error_perm, resp&lt;BR /&gt;ftplib.error_perm: 553 Can't open that file: No such file or directory&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 09 Mar 2021 14:42:45 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/uploading-pdf-through-ftp-using-python/m-p/1034453#M60309</guid>
      <dc:creator>Bubacz_Hannah</dc:creator>
      <dc:date>2021-03-09T14:42:45Z</dc:date>
    </item>
    <item>
      <title>Re: Uploading PDF through FTP using Python</title>
      <link>https://community.esri.com/t5/python-questions/uploading-pdf-through-ftp-using-python/m-p/1034457#M60310</link>
      <description>&lt;P&gt;Change the working directory before you call the STOR command to copy the file.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;session.cwd('/srv/ftp/pub/crimemaps')
# Sending the file
print('Sending file')
session.storbinary('STOR ' + filename, file_object)
print('Sent file')&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 09 Mar 2021 14:50:35 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/uploading-pdf-through-ftp-using-python/m-p/1034457#M60310</guid>
      <dc:creator>BlakeTerhune</dc:creator>
      <dc:date>2021-03-09T14:50:35Z</dc:date>
    </item>
    <item>
      <title>Re: Uploading PDF through FTP using Python</title>
      <link>https://community.esri.com/t5/python-questions/uploading-pdf-through-ftp-using-python/m-p/1034464#M60313</link>
      <description>&lt;PRE&gt;filename = 'TEST12142020.pdf'&lt;BR /&gt;filepath = r'G:\GIS\Departments\ItmdGis\Users\hbubac\Data and Scripts\Crime Maps\new scripts\{}'.format(filename)&lt;BR /&gt;file_object = open(filepath, 'rb')&lt;BR /&gt;print ('Opened file')&lt;BR /&gt;&lt;BR /&gt;# Sending the file&lt;BR /&gt;session.cwd('/srv/ftp/pub/crimemaps')&lt;BR /&gt;print('Sending file')&lt;BR /&gt;session.storbinary('STOR ' + filename, file_object)&lt;BR /&gt;print('Sent file')&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;ERROR:&lt;/P&gt;&lt;PRE&gt; &amp;lt;module&amp;gt;&lt;BR /&gt;session.cwd('/srv/ftp/pub/crimemaps')&lt;BR /&gt;File "C:\Python27\ArcGIS10.5\lib\ftplib.py", line 562, in cwd&lt;BR /&gt;return self.voidcmd(cmd)&lt;BR /&gt;File "C:\Python27\ArcGIS10.5\lib\ftplib.py", line 254, in voidcmd&lt;BR /&gt;return self.voidresp()&lt;BR /&gt;File "C:\Python27\ArcGIS10.5\lib\ftplib.py", line 229, in voidresp&lt;BR /&gt;resp = self.getresp()&lt;BR /&gt;File "C:\Python27\ArcGIS10.5\lib\ftplib.py", line 224, in getresp&lt;BR /&gt;raise error_perm, resp&lt;BR /&gt;ftplib.error_perm: 550 Can't change directory to /srv/ftp/pub/crimemaps: No such file or directory&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 09 Mar 2021 14:58:15 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/uploading-pdf-through-ftp-using-python/m-p/1034464#M60313</guid>
      <dc:creator>Bubacz_Hannah</dc:creator>
      <dc:date>2021-03-09T14:58:15Z</dc:date>
    </item>
  </channel>
</rss>

