Skip to content Skip to sidebar Skip to footer

"553 Can't Open That File: No Such File Or Directory" When Uploading A File Using Python Ftplib

Got this FTP upload code. This example has the correct data so you can try it. The path is correct since I got it from select box (filename = askopenfilename()) I get: ftplib.erro

Solution 1:

You are trying to save the file on the remote server using a local path. Note how you use the same path with local open and remote storbinary. I'm quite sure your remote server has a different directory structure.

If you want to upload the file to your FTP home directory, use just a filename:

ftp.storbinary("STOR " + os.path.basename(filename), file)

If you want to upload to a specific folder, use real path on your FTP server, like:

ftp.storbinary("STOR htdocs/" + os.path.basename(filename), file)

Post a Comment for ""553 Can't Open That File: No Such File Or Directory" When Uploading A File Using Python Ftplib"