Hi,
I'm a newbie to Python and trying to write my first FTP script. Here's the code:

from ftplib import FTP
ftp = FTP("LoginServer.com")  
ftp.login("LoginID", "Password")
# open the file to read it
f = open("C:/Users/MyDocs/Documents/Python/test.txt", "r")
# Open directory
ftp.cwd("/")
# save file 
ftp.storbinary("STOR test.txt", f)
ftp.quit()
f.close()

I'm getting this error:

Traceback (most recent call last):
  File "C:\Users\MyDocs\Documents\Python\FTP-Real.py", line 3, in <module>
    ftp.login("LoginID", "Password")
  File "C:\Python32\lib\ftplib.py", line 396, in login
    if resp[0] == '3': resp = self.sendcmd('PASS ' + passwd)
  File "C:\Python32\lib\ftplib.py", line 255, in sendcmd
    return self.getresp()
  File "C:\Python32\lib\ftplib.py", line 229, in getresp
    raise error_perm(resp)
ftplib.error_perm: 530 User UserID cannot log in, home directory inaccessible.

Is this a permissions issue with the target root folder and I need some special access rights to it?

Any help will be greatly appreciated as I'm new to Python.

You specify path relative path relative to ftp root directory, you have Windows file path specified. Check first that the ftp you try works from command line ftp, before trying to do it with ftplib.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.