Search code examples
pythonftpftplib

FTP Python 550 Parameter Incorrect Filename Error


I'm using ftplib on Python to upload an image. Everything was working fine until it started giving me this error:

ftplib.error_perm: 550 The parameter is incorrect.

Here is the code:

    fileNameA = "2020-04-08_00:15.png" # This one gives the error
    fileNameB = "test.png" # This one works well

    cmd = "STOR " + fileName

    f.storbinary(cmd, file)

When it attempts to upload the file using the first name (generated) it gives the error. However, if I just use test.png it works well.

Any help would be appreciated. Thank you!


Solution

  • Most of the time when using filenames with ftplib, the error is caused because of the :. Change them to underscores, and it should work correctly.

    From

    fileNameA = "2020-04-08_00:15.png"
    

    to

    fileNameA = "2020-04-08_00_15.png"