Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to upload a file (using FTP) to a password protected folder in C#?

I have password-protected a folder on my web server using CPanel (HTTP?). I am trying to upload a file via FTP in C#, but I keep getting this error:

The remote server returned an error: (553) File name not allowed.

When I use the same code to upload to a non-password protected folder I don't get any errors. There is nothing wrong with the file name as far as I can tell.

So what would the problem be? How do I supply credentials to the password-protected folder (not talking about the FTP credentials, because obviously those are authenticating properly if a 553 error code is being returned)?

like image 276
Alec Baldwin's Bald Twin Avatar asked Dec 12 '10 14:12

Alec Baldwin's Bald Twin


1 Answers

I realized what the problem was (it was totally unrelated to password-protection). The root directory for the FTP account I was using was actually a sub-directory inside another directory. The directory I was trying to access was:

www.example.com/example1/abc/

But the highest directory that the FTP account had permissions to was:

www.example.com/example1/

So I was specifying /example1/abc as the directory to upload the file to, where as should it should have simply been /abc/, since it is all relative to the FTP account's root directory and not the root of the entire domain. So I was authenticating correctly, but because I was specifying the wrong relative directory the 553 error code was being returned.

Newbie mistake. ;)

like image 113
Alec Baldwin's Bald Twin Avatar answered Sep 30 '22 17:09

Alec Baldwin's Bald Twin