0 votes
by (320 points)

Hello Team,

We are getting the below exception while uploading a file using PutFile method.

===========Error Information=============================
15:26:18.227 Info Info: Connecting to ftp2.ftccc.net:21 using Ftp 4.0.4546.0.
15:26:18.229 Info Info: Using proxy none.
15:26:18.259 Info Response: 220 Titan FTP Server 7.13.903 Ready.
15:26:18.262 Info Command: USER aimsupload@ftccc.net
15:26:18.297 Info Response: 331 User name okay, need password.
15:26:18.299 Info Command: PASS *********
15:26:18.379 Info Response: 230-Welcome aimsupload@ftccc.net from 191.236.110.177. You are now logged in to the server.
15:26:18.381 Info Response: 230 User logged in, proceed.
15:26:18.384 Info Command: FEAT
15:26:18.396 Info Response: 211-Extensions Supported
15:26:18.399 Info Response: COMB
15:26:18.401 Info Response: MLST type;size;modify;create;perm*;
15:26:18.404 Info Response: SIZE
15:26:18.407 Info Response: MDTM
15:26:18.409 Info Response: MFMT
15:26:18.411 Info Response: MFCT
15:26:18.414 Info Response: EPRT
15:26:18.417 Info Response: EPSV
15:26:18.419 Info Response: XCRC
15:26:18.421 Info Response: REST STREAM
15:26:18.423 Info Response: DQTA
15:26:18.425 Info Response: 211 End
15:26:18.429 Info Command: TYPE A
15:26:18.442 Info Response: 200 Type set to A.
15:26:18.444 Info Command: PASV
15:26:18.461 Info Response: 227 Entering Passive Mode (12,53,113,138,18,171).
15:26:18.477 Info Command: STOR //SALCINV_20150915152617.AMI
15:26:18.492 Info Response: 550 Requested action not taken, file not found or no access.
***15:26:18.494 Error Info: Rebex.Net.FtpException: Requested action not taken, file not found or no access (550).
at Rebex.Net.Ftp.2aYAeNZ(String , Boolean , OTxlj , Int64 , String , String , Int64 , FtpTransferState )
at Rebex.Net.Ftp.y7ABW(String , String , Stream , Int64 , Int64 , 27NpLhZ )***

=====================================================================

In this FTP, we don't have an access to get the list of files/folders for this user.
With out verifying/getting the list, just we need to upload a file in ftp's root folder. Please help me how I can achieve this. We can put the file using Windows File Explorer.
Please help me to resolve this error.

Thanks & Regards
Naga Suresh D

Applies to: Rebex FTP/SSL

2 Answers

0 votes
by (58.9k points)
edited by

Hello,

the Ftp.PutFile method is suitable for this purpose. it does not perform any listing prior to the file upload.

Are you able to upload the file to the FTP server root with the short code below?

Ftp client = new Ftp();
ftp.LogWriter = new Rebex.FileLogWriter(@"C:\logs\ftp-log.txt", Rebex.LogLevel.Debug);
client.Connect("ftp2.ftccc.net");
client.Login("ftp2.ftccc.net", "your-password");

// upload the local file to FTP server's root
client.PutFile(@"C:\data\SALCINV_20150915152617.AMI", "/SALCINV_20150915152617.AMI");
client.Disconnect();

Please give it a try and let me know whether it works.

by (320 points)
Hello,

I have tried with the same code which you provided. Issue is still reproducing. See below error log.

================================================================

2015-09-18 16:00:31.796 Opening log file.
2015-09-18 16:00:31.812 INFO Ftp(5)[1] Info: Connecting to ftp2.ftccc.net:21 using Ftp 4.0.4546.0.
2015-09-18 16:00:31.812 INFO Ftp(5)[1] Info: Using proxy none.
2015-09-18 16:00:31.855 DEBUG Ftp(5)[1] Info: Connection succeeded.
2015-09-18 16:00:31.871 INFO Ftp(5)[1] Response: 220 Titan FTP Server 7.13.903 Ready.
2015-09-18 16:00:31.879 INFO Ftp(5)[1] Command: USER aimsupload@ftccc.net
2015-09-18 16:00:31.915 INFO Ftp(5)[1] Response: 331 User name okay, need password.
2015-09-18 16:00:31.916 INFO Ftp(5)[1] Command: PASS *********
2015-09-18 16:00:31.996 INFO Ftp(5)[1] Response: 230-Welcome aimsupload@ftccc.net from 191.236.110.177. You are now logged in to the server.
2015-09-18 16:00:31.996 INFO Ftp(5)[1] Response: 230 User logged in, proceed.
2015-09-18 16:00:31.998 INFO Ftp(5)[1] Command: FEAT
2015-09-18 16:00:32.010 INFO Ftp(5)[1] Response: 211-Extensions Supported
2015-09-18 16:00:32.010 INFO Ftp(5)[1] Response:  COMB
2015-09-18 16:00:32.011 INFO Ftp(5)[1] Response:  MLST type*;size*;modify*;create*;perm*;
2015-09-18 16:00:32.011 INFO Ftp(5)[1] Response:  SIZE
2015-09-18 16:00:32.011 INFO Ftp(5)[1] Response:  MDTM
2015-09-18 16:00:32.011 INFO Ftp(5)[1] Response:  MFMT
2015-09-18 16:00:32.011 INFO Ftp(5)[1] Response:  MFCT
2015-09-18 16:00:32.011 INFO Ftp(5)[1] Response:  EPRT
2015-09-18 16:00:32.011 INFO Ftp(5)[1] Response:  EPSV
2015-09-18 16:00:32.011 INFO Ftp(5)[1] Response:  XCRC
2015-09-18 16:00:32.011 INFO Ftp(5)[1] Response:  REST STREAM
2015-09-18 16:00:32.011 INFO Ftp(5)[1] Response:  DQTA
2015-09-18 16:00:32.011 INFO Ftp(5)[1] Response: 211 End
2015-09-18 16:00:34.149 DEBUG Ftp(5)[1] Info: Starting data transfer.
2015-09-18 16:00:34.150 INFO Ftp(5)[1] Command: TYPE I
2015-09-18 16:00:34.164 INFO Ftp(5)[1] Response: 200 Type set to I.
2015-09-18 16:00:34.166 INFO Ftp(5)[1] Command: PASV
2015-09-18 16:00:34.182 INFO Ftp(5)[1] Response: 227 Entering Passive Mode (12,53,113,138,12,176).
2015-09-18 16:00:34.186 DEBUG Ftp(5)[1] Info: Establishing data connection to 12.53.113.138:3248.
2015-09-18 16:00:34.199 INFO Ftp(5)[1] Command: STOR /test123.txt
2015-09-18 16:00:34.215 INFO Ftp(5)[1] Response: 550 Requested action not taken, file not found or no access.
2015-09-18 16:00:34.217 DEBUG Ftp(5)[1] Info: Error while starting data transfer: Rebex.Net.FtpException: Requested action not taken, file not found or no access (550).
   at Rebex.Net.Ftp.2aYAeNZ(String , Boolean , OTxlj , Int64 , String , String , Int64 , FtpTransferState )
2015-09-18 16:00:34.218 DEBUG Ftp(5)[1] Info: Error while initializing data connection.
2015-09-18 16:00:34.219 ERROR Ftp(5)[1] Info: Rebex.Net.FtpException: Requested action not taken, file not found or no access (550).
   at Rebex.Net.Ftp.2aYAeNZ(String , Boolean , OTxlj , Int64 , String , String , Int64 , FtpTransferState )
   at Rebex.Net.Ftp.y7ABW(String , String , Stream , Int64 , Int64 , 27NpLhZ )

================================================================

Now we are able to upload the file from both FileZilla and Windows File Explorer.
We are having this issue with only Rebex PutFile method.

Please help me to resolve this error.
0 votes
by (73.5k points)
edited by

This is really strange error message. Perhaps the server doesn't allow write access to the FTP root folder, or it doesn't like absolute paths. Can you please try the following code?

The code will upload the file into current working directory. You can determine what is your current working directory using the client.GetCurrentDirectory() method. To change working directory use the client.ChangeDirectory() method.

If it still doesn't work. Please send us FileZilla log for comparison.

Ftp client = new Ftp();
client.LogWriter = new Rebex.FileLogWriter(@"C:\logs\ftp-log.txt", Rebex.LogLevel.Debug);
client.Connect("ftp2.ftccc.net");
client.Login("user-name", "user-password");

// change working directory if needed
//client.ChangeDirectory("/");

// upload the local file to current working directory 
// at the FTP server
client.PutFile(@"C:\data\test123.txt", "test123.txt");
client.Disconnect();
by (320 points)
Thanks for your reply Lukas.
I tried the same code to get the current directory and change the directory.
The current directory returns as "/ftp/incoming". While changing the directory also we are getting the same error. Please see the below error log.

=============================================================

2015-09-18 23:38:49.273 INFO Ftp(5)[1] Info: Connecting to ftp2.ftccc.net:21 using Ftp 4.0.4546.0.
2015-09-18 23:38:49.273 INFO Ftp(5)[1] Info: Using proxy none.
2015-09-18 23:38:49.320 DEBUG Ftp(5)[1] Info: Connection succeeded.
2015-09-18 23:38:49.340 INFO Ftp(5)[1] Response: 220 Titan FTP Server 7.13.903 Ready.
2015-09-18 23:38:49.349 INFO Ftp(5)[1] Command: USER aimsupload@ftccc.net
2015-09-18 23:38:49.431 INFO Ftp(5)[1] Response: 331 User name okay, need password.
2015-09-18 23:38:49.432 INFO Ftp(5)[1] Command: PASS *********
2015-09-18 23:38:49.521 INFO Ftp(5)[1] Response: 230-Welcome aimsupload@ftccc.net from 191.236.110.177. You are now logged in to the server.
2015-09-18 23:38:49.521 INFO Ftp(5)[1] Response: 230 User logged in, proceed.
2015-09-18 23:38:49.524 INFO Ftp(5)[1] Command: FEAT
2015-09-18 23:38:49.537 INFO Ftp(5)[1] Response: 211-Extensions Supported
2015-09-18 23:38:49.537 INFO Ftp(5)[1] Response:  COMB
2015-09-18 23:38:49.537 INFO Ftp(5)[1] Response:  MLST type*;size*;modify*;create*;perm*;
2015-09-18 23:38:49.537 INFO Ftp(5)[1] Response:  SIZE
2015-09-18 23:38:49.537 INFO Ftp(5)[1] Response:  MDTM
2015-09-18 23:38:49.537 INFO Ftp(5)[1] Response:  MFMT
2015-09-18 23:38:49.537 INFO Ftp(5)[1] Response:  MFCT
2015-09-18 23:38:49.537 INFO Ftp(5)[1] Response:  EPRT
2015-09-18 23:38:49.537 INFO Ftp(5)[1] Response:  EPSV
2015-09-18 23:38:49.537 INFO Ftp(5)[1] Response:  XCRC
2015-09-18 23:38:49.537 INFO Ftp(5)[1] Response:  REST STREAM
2015-09-18 23:38:49.537 INFO Ftp(5)[1] Response:  DQTA
2015-09-18 23:38:49.537 INFO Ftp(5)[1] Response: 211 End
2015-09-18 23:38:49.541 INFO Ftp(5)[1] Command: PWD
2015-09-18 23:38:49.554 INFO Ftp(5)[1] Response: 257 "/ftp/incomming/" is current directory.
2015-09-18 23:38:54.754 INFO Ftp(5)[1] Command: CWD /
2015-09-18 23:38:54.769 INFO Ftp(5)[1] Response: 550 Requested action not taken, file not found or no access.
2015-09-18 23:38:54.773 ERROR Ftp(5)[1] Info: Rebex.Net.FtpException: Requested action not taken, file not found or no access (550).
   at Rebex.Net.Ftp.1SAJuN(Int32 , Boolean )
   at Rebex.Net.Ftp.2Dt7i1Z(String )

================================================================

Please help me to resolve this issue. Our customers are asking to fix this asap.
Because the users are able to export the files by using File Zilla and Windows File Explorer. In Rebex only we are getting this issue.

File Zilla upload successful log
----------------------------------------------
Status:    Resolving address of ftp2.ftccc.net
Status:    Connecting to 12.53.113.138:21...
Status:    Connection established, waiting for welcome message...
Response:    220 Titan FTP Server 7.13.903 Ready.
Command:    USER aimsupload@ftccc.net
Response:    331 User name okay, need password.
Command:    PASS *********
Response:    230-Welcome aimsupload@ftccc.net from 191.236.110.177. You are now logged in to the server.
Response:    230 User logged in, proceed.
Command:    SYST
Response:    215 UNIX Type: L8
Command:    FEAT
Response:    211-Extensions Supported
Response:     COMB
Response:     MLST type*;size*;modify*;create*;perm*;
Response:     SIZE
Response:     MDTM
Response:     MFMT
Response:     MFCT
Response:     EPRT
Response:     EPSV
Response:     XCRC
Response:     REST STREAM
Response:     DQTA
Response:    211 End
Status:    Connected
Status:    Retrieving directory listing...
Command:    PWD
Response:    257 "/ftp/incomming/" is current directory.
Command:    TYPE I
Response:    200 Type set to I.
Command:    PASV
Response:    227 Entering Passive Mode (12,53,113,138,16,25).
Command:    MLSD
Response:    150 File status okay; about to open data connection.
Response:    226 Closing data connection. Transferred 75 bytes.
Status:    Directory listing successful
Status:    Resolving address of ftp2.ftccc.net
Status:    Connecting to 12.53.113.138:21...
Status:    Connection established, waiting for welcome message...
Response:    220 Titan FTP Server 7.13.903 Ready.
Command:    USER aimsupload@ftccc.net
Response:    331 User name okay, need password.
Command:    PASS *********
Response:    230-Welcome aimsupload@ftccc.net from 191.236.110.177. You are now logged in to the server.
Response:    230 User logged in, proceed.
Status:    Connected
Status:    Starting upload of P:\Users\team8e\Desktop\test1.txt
Command:    CWD /ftp/incomming
Response:    250 Directory changed to "/ftp/incomming/"
Command:    PWD
Response:    257 "/ftp/incomming/" is current directory.
Command:    TYPE A
Response:    200 Type set to A.
Command:    PASV
Response:    227 Entering Passive Mode (12,53,113,138,16,26).
Command:    STOR test1.txt
Response:    150 File status okay; about to open data connection.
Response:    226 Closing data connection. Transferred 4 bytes in 1 seconds. 0KB/second.
Status:    File transfer successful, transferred 4 bytes in 1 second
Status:    Retrieving directory listing...
Command:    TYPE I
Response:    200 Type set to I.
Command:    PASV
Response:    227 Entering Passive Mode (12,53,113,138,16,27).
Command:    MLSD
Response:    150 File status okay; about to open data connection.
Response:    226 Closing data connection. Transferred 155 bytes.
Status:    Directory listing successful
=============================================================
by (320 points)
Please help me to resolve this issue asap.
by (58.9k points)
edited by
Hello and thank you for the FileZilla log!

From the log you sent, we can see that FileZilla client uploads the file into the "/ftp/incomming" directory, not into the root directory ["/"]  where you obviously do not have sufficent rights.

Achieving the FileZilla behavior with Rebex FTP component is quite simple, just try the below code snippet:

    Ftp client = new Ftp();
    // connect and login

    client.ChangeDirectory("/ftp/incomming");

    // upload the 'file.txt' into the current directory
    client.PutFile(@"C:\data\file.txt", "file.txt");

Let me know whether you are able to upload now.
by (320 points)
Thanks for your reply.

We can see the same current directory "/ftp/incoming" in our Rebex log also.
If we connect to this FTP with the given credentials, by default it connects to the "/ftp/incoming" directory.

I am going to check the code which you suggested.

But my doubt is that necessary to change the directory? Because in Rebex also we are getting the same current directory.
by (320 points)
I am facing the same issue even after executed this code. See below Rebex error log.

===================================================================
2015-09-21 18:11:30.993 INFO Ftp(5)[1] Info: Connecting to ftp2.ftccc.net:21 using Ftp 4.0.4546.0.
2015-09-21 18:11:30.994 INFO Ftp(5)[1] Info: Using proxy none.
2015-09-21 18:11:31.037 DEBUG Ftp(5)[1] Info: Connection succeeded.
2015-09-21 18:11:31.052 INFO Ftp(5)[1] Response: 220 Titan FTP Server 7.13.903 Ready.
2015-09-21 18:11:31.060 INFO Ftp(5)[1] Command: USER aimsupload@ftccc.net
2015-09-21 18:11:31.096 INFO Ftp(5)[1] Response: 331 User name okay, need password.
2015-09-21 18:11:31.097 INFO Ftp(5)[1] Command: PASS *********
2015-09-21 18:11:31.175 INFO Ftp(5)[1] Response: 230-Welcome aimsupload@ftccc.net from 191.236.110.177. You are now logged in to the server.
2015-09-21 18:11:31.175 INFO Ftp(5)[1] Response: 230 User logged in, proceed.
2015-09-21 18:11:31.176 INFO Ftp(5)[1] Command: FEAT
2015-09-21 18:11:31.190 INFO Ftp(5)[1] Response: 211-Extensions Supported
2015-09-21 18:11:31.190 INFO Ftp(5)[1] Response:  COMB
2015-09-21 18:11:31.190 INFO Ftp(5)[1] Response:  MLST type*;size*;modify*;create*;perm*;
2015-09-21 18:11:31.190 INFO Ftp(5)[1] Response:  SIZE
2015-09-21 18:11:31.190 INFO Ftp(5)[1] Response:  MDTM
2015-09-21 18:11:31.190 INFO Ftp(5)[1] Response:  MFMT
2015-09-21 18:11:31.190 INFO Ftp(5)[1] Response:  MFCT
2015-09-21 18:11:31.190 INFO Ftp(5)[1] Response:  EPRT
2015-09-21 18:11:31.190 INFO Ftp(5)[1] Response:  EPSV
2015-09-21 18:11:31.190 INFO Ftp(5)[1] Response:  XCRC
2015-09-21 18:11:31.190 INFO Ftp(5)[1] Response:  REST STREAM
2015-09-21 18:11:31.190 INFO Ftp(5)[1] Response:  DQTA
2015-09-21 18:11:31.190 INFO Ftp(5)[1] Response: 211 End
2015-09-21 18:11:31.193 INFO Ftp(5)[1] Command: PWD
2015-09-21 18:11:31.206 INFO Ftp(5)[1] Response: 257 "/ftp/incomming/" is current directory.
2015-09-21 18:11:32.886 INFO Ftp(5)[1] Command: CWD /ftp/incomming
2015-09-21 18:11:32.900 INFO Ftp(5)[1] Response: 250 Directory changed to "/ftp/incomming/"
2015-09-21 18:11:32.900 INFO Ftp(5)[1] Command: PWD
2015-09-21 18:11:32.913 INFO Ftp(5)[1] Response: 257 "/ftp/incomming/" is current directory.
2015-09-21 18:11:35.238 DEBUG Ftp(5)[1] Info: Starting data transfer.
2015-09-21 18:11:35.238 INFO Ftp(5)[1] Command: TYPE I
2015-09-21 18:11:35.251 INFO Ftp(5)[1] Response: 200 Type set to I.
2015-09-21 18:11:35.254 INFO Ftp(5)[1] Command: PASV
2015-09-21 18:11:35.271 INFO Ftp(5)[1] Response: 227 Entering Passive Mode (12,53,113,138,11,196).
2015-09-21 18:11:35.275 DEBUG Ftp(5)[1] Info: Establishing data connection to 12.53.113.138:3012.
2015-09-21 18:11:35.290 INFO Ftp(5)[1] Command: STOR /test10.txt
2015-09-21 18:11:35.320 INFO Ftp(5)[1] Response: 550 Requested action not taken, file not found or no access.
2015-09-21 18:11:35.323 DEBUG Ftp(5)[1] Info: Error while starting data transfer: Rebex.Net.FtpException: Requested action not taken, file not found or no access (550).
   at Rebex.Net.Ftp.2aYAeNZ(String , Boolean , OTxlj , Int64 , String , String , Int64 , FtpTransferState )
2015-09-21 18:11:35.324 DEBUG Ftp(5)[1] Info: Error while initializing data connection.
2015-09-21 18:11:35.325 ERROR Ftp(5)[1] Info: Rebex.Net.FtpException: Requested action not taken, file not found or no access (550).
   at Rebex.Net.Ftp.2aYAeNZ(String , Boolean , OTxlj , Int64 , String , String , Int64 , FtpTransferState )
   at Rebex.Net.Ftp.y7ABW(String , String , Stream , Int64 , Int64 , 27NpLhZ )

==================================================================
by (58.9k points)
After you login into any FTP server, the server changes you into what we call "home directory". This is the directory that you get if you call Ftp.GetCurrentDirectory() after the Ftp.Login method.

The "home directory" can be the actual root (e.g. "/") but it can also be some other directory. In your case it seems to be "/ftp/incomming".

So if you are already in the "ftp/incomming" directory after logging in, then you do not have to call the ftp.ChangeDirectory method.

So your code would be:

     Ftp client = new Ftp();
     client.Connect("server");
    client.Login("user", "password");

     // upload the 'file.txt' into the user's home directory
     client.PutFile(@"C:\data\file.txt", "file.txt");
by (320 points)
Yes you are correct. The same code I am using. But I am facing this issue.
by (58.9k points)
in your above log I can see that you are still calling the PutFile method with a bad argument.

2015-09-21 18:11:35.290 INFO Ftp(5)[1] Command: STOR /test10.txt

make sure that the second argument does not start with a leading slash "/". If you include a leading slash into the remoteFilePath, then it will instruct Rebex FTP to upload into the actual root where you do not have access!

So this will work and upload into the current directory:

    client.PutFile("file.txt", "file.txt");  // works

this will not work with your server:

    client.PutFile("file.txt", "/file.txt");  // uploads the file into the FTP root directory - causes no access exception with your server!
by (58.9k points)
So it is the slash that is causing troubles. Please check on that and let me know.
by (320 points)
Great.....
Issue is fixed. Thanks to identified the issue.

Actually we have a common method to upload the files into FTP. there we are passing Empty value for this FTP. Because by default File Zilla also connects to the same folder with out changing the directory to "/ftp/incoming".

So we have also tried like the same.

Now issue got fixed.

Thanks alot....
by (58.9k points)
Ok, I am glad to hear that. Thank you!
by (320 points)
May I know how the FileZilla and Windows File Explorer are handling this?

If we know the generic fix, it is very useful for other FTPs.
by (58.9k points)
edited by
I don't know what you mean by generic fix... If your requirement is upload to home directory, I already provided a simple code to achieve this with Rebex which will work with any FTP server.  If apart from this, you will also need to upload to some other directories (e.g. to "non-home directories") then you have to know what is the target directory for each FTP server. And you will have to have a parameter / config value / GUI pick in your program that you will use to determine where exactly you need to upload.

For sample implementation of a GUI FTP client, please check our Ftp WinformClient sample (http://www.rebex.net/sample/ftp-winform-client-classic/). The sample source code comes as a part of your Rebex FTP/SSL package.

And by the way, could you please share your order ID or the email that you used to buy your Rebex FTP license? Unfortunatelly, I was unable to find your order in our system.
by (320 points)
Thank you.

We have a different email id which has Rebex license. Unfortunately we missed the password. So we created an anonymous user in Rebex and created this ticket.
by (58.9k points)
Ok, no problem, but what is the registered email? You can send it to us privately to support@rebex.net and I will associate the forum account with your license then. Thank you.
by (58.9k points)
You can reset your account password at https://www.rebex.net/userLostPassword.aspx
...