Python Forum
Unable to upload file using FTP
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Unable to upload file using FTP
#1
Hello,
I have a stange problem
I'm using this simple code:
ftp = FTP('10.0.0.1', timeout=60)
    try:
        ftp.login(user='user', passwd='pass')
    except error_perm as msg:
        print(f"FTP error: {msg}")
       # return "Wrong User or Password"
    except Exception as e1:
        print(e1)
        print("Error in FTP Login!")
       # return "Unknown Error"
    else:
        try:
            file_to_upload = open(filename, 'rb')
            ftp.storbinary('STOR test.txt', file_to_upload)
            UploadOk = "OK"
            return "FTP success"
        except Exception as e:
            print('my error')
            print(e)
            UploadOk = "Problem"
            return "FTP Error " + str(e)
        finally:
            print("status " + UploadOk)
            file_to_upload.close()
            ftp.close()
I can see a FTP session is made , but the file won't uplaod
O get this error:
FTP Error [WinError 10060] A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond
when I ty to upload to another device (the same file, same code) everything is working - so I know the code\file is OK
the file is test.txt size 1 kb , there is more then 100MB free in the remote device

what could be the reason for the error? why the file isn't been upload ?
Reply
#2
Do you have access to the server? Can you check the logs for the FTP server running on there?
Reply
#3
it's a home router
no so much logs
all I can see it
Dec/23/2021 14:29:35 user user logged in from 10.0.0.254 via ftp
Dec/23/2021 14:29:57 user user logged out from 10.0.0.254 via ftp
but I have found the problem
it seem that only Port 22 TCP is open , so the connection was made but a port to transer the data is block

when I remove this rule - it works
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Error (Errno 2), File upload with the Flask framework and a public IP Username_Python1 0 271 Mar-28-2024, 01:46 PM
Last Post: Username_Python1
  '' FTP '' File upload with a specified string and rename midomarc 1 1,163 Apr-17-2023, 03:04 AM
Last Post: bowlofred
  Unable to capture all images of a multipage TIFF file in a merge bendersbender 0 2,218 Nov-19-2020, 03:09 PM
Last Post: bendersbender
  unable to write to log file Mekala 2 2,084 Aug-12-2020, 11:02 PM
Last Post: Mekala
  Unable to parse xml file avi1990pr 1 11,347 Jun-21-2019, 04:56 AM
Last Post: mcmxl22
  upload Files to FTP and file name is Chinese mollychen 2 2,603 Apr-15-2019, 01:01 AM
Last Post: mollychen
  Fatal Python error: Py_Initialize: unable to load the file system codec ecg1g15 0 3,576 Feb-12-2019, 12:16 PM
Last Post: ecg1g15
  Unable to open file ayaz786amd 7 4,793 Nov-21-2018, 05:31 AM
Last Post: ayaz786amd
  how to upload a file to my gmail driver after login ?? evilcode1 5 4,171 Nov-06-2018, 07:33 AM
Last Post: evilcode1
  Unable to read data from string base64 representing a .xlsx file max 2 15,329 Apr-05-2018, 07:58 PM
Last Post: max

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020