Unable to ftp a file using python ftplib, but successful using curl
<p>I receive the following error when uploading a small text file to an ftp site when using python's ftplib:</p>

<pre><code>      File "ftpuploader.py", line 13, in uploadFilePath
    ftp.storbinary("STOR {}".format(filepath), file)
  File "/usr/lib64/python2.7/ftplib.py", line 471, in storbinary
    conn = self.transfercmd(cmd, rest)
  File "/usr/lib64/python2.7/ftplib.py", line 376, in transfercmd
    return self.ntransfercmd(cmd, rest)[0]
  File "/usr/lib64/python2.7/ftplib.py", line 358, in ntransfercmd
    resp = self.sendcmd(cmd)
  File "/usr/lib64/python2.7/ftplib.py", line 249, in sendcmd
    return self.getresp()
  File "/usr/lib64/python2.7/ftplib.py", line 224, in getresp
    raise error_perm, resp
ftplib.error_perm: 553 Could not create file.
</code></pre>

<p>I am using the following code successfully when connecting to another system. I can log in, change directories, but am unable to create the file. I can load a file using either filezilla or a simple curl command,  curl -T '/path/to/file' <a href="ftp://192.168.18.75" rel="nofollow">ftp://192.168.18.75</a> --user admin:password</p>

<pre><code>ftp = FTP(address)
ftp.login(username, password)
ftp.cwd('/gui')
file = open(filepath, 'rb')
ftp.storbinary("STOR {}".format(filepath), file)
ftp.retrlines('LIST') # list directory contents     
file.close()
ftp.quit()
</code></pre>

<p>any ideas?</p>

<p>You are passing a path to a local path to the <code>STOR</code> command (the same path you use with the <code>open(filepath, 'rb')</code>).</p>

<p>While with the CURL, you do not specify any path to the remote file. So the file gets uploaded to the current FTP working directory.</p>

<p>As already suggested in the comments by @acw1668, use the:</p>

<pre><code>ftp.storbinary("STOR {}".format(os.path.basename(filepath)), file)
</code></pre>

python curl ftp