3

I am struggling to upload file to my FTP server. Please advise what is wrong in code below:

host: someserver.com

path: ./my_folder/at_this_server

target: 'test.pdf'

with ftputil.FTPHost(ftp_settings['host'],
                     ftp_settings['user'],
                     ftp_settings['password'],
                     ftp_settings['port']) as ftp_host:
    safe_chdir(ftp_host, ftp_settings['path']) # change FTP dir
    ftp_host.upload_if_newer('local_test.pdf', 'test.pdf')

There is successfully execute the command upload_if_newer() or upload(), but I don't see any uploaded file to the FTP folder.

UPDATE

I found that file is uploading to host+"/my_folder" only instead of host+"/my_folder/at_this_server".

Community
  • 1
  • 1
SpanishBoy
  • 2,105
  • 6
  • 28
  • 51

1 Answers1

2

1) Check the result of ftp_host.upload_if_newer('local_test.pdf', 'test.pdf'). If it is True then the file was copied.
2) Are you sure that safe_chdir function is correct? You could check that current directory on FTP changed using ftp_host.getcwd(). Try to upload file using full path instead of changing FTP dir.
3) Check access rights.

Delimitry
  • 2,987
  • 4
  • 30
  • 39