I get "IT IS CONNECTED" on my console. Now the problem...
after confirming that client.IsConnected(), the following three calls all return nothing, do nothing (no error) and the booleans simply return false...
files_array is empty but I see the files in the FTP directory in explorer
success is always false
success2 is always false and the file is never uploaded to the ftp site.
Again, the connection to the ftp site is established in the code with the same credentials I use when I manually access the ftp in explorer. But everything else just equates to nulls and falses (sans errors). Would anybody have an idea what is going on? Is it maybe another read/write security layer for the server the code is running at the FTP site/directory although the code authenticates and connects?
Thank you so much for reading and for your time.
and it's still showing a connection and login_state=true. i deliberately entered bogus login credentials to bomb it and it doesn't seem to care.
This is telling me that I or the server where I'm running this code are either blocked outright from the ftp site (but I access it manually in explorer) or somehow I'm not hitting the actual ftp site? But it's the exact url addy I enter into explorer which I use as the client.connect arg.
Any help would be so appreciated. thank you again.
P.S. I accdientally started a new thread with this response. I am trying to get rid of it. I really apologize for that. I'm typing this while coding at the same time.
my target ftp server is not a dedicated ftp server...there is a sub-directory which is set as the FTP home or whatever...
for example, I enter the ip 22.214.171.124 into IE address bar, I get the server home page (http://126.96.36.199)
so I need to enter ftp://188.8.131.52 in the IE address bar to open the FTP home directory (and get authenticated) on the server...
So, the FTPClient connect code must be hitting the http server...which is why i am getting nulls on ftp specific calls and it doesn't care about ftp authentication. The problem is for FTPClient, I can't enter ftp:// in the connect arg...
It bombs it...
What is interesting is the exception is not an org.apache.commons thing, it's java.net.
Well, that's what I have so far. i guess I like to think out loud and outline my steps in case somebody comes along later. If anybody has any input, I still would so appreciate it, and thank you to anybody for reading this far.
I doubt that, since you said that isConnected() returns true - since the FTP client code only understands FTP, it can't be talking to the HTTP server.
the FTPClient connect code must be hitting the http server
That won't work, as that method takes a hostname as parameter, not an URL.
java.net.unknownhostException ftp://184.108.40.206 What is interesting is the exception is not an org.apache.commons thing, it's java.net.
That's to be expected, as the Apache code relies on the JRE networking code for low-level stuff.
That assumes that "sub1" is a top-level directory - is it? If it's a subdirectory, leave out the slash.
I agree with Paul that a good first step would be to use a command-line FTP client and make sure it can connect, and subsequently perform the operations you're trying to automate.
1. Telnet confirmed port 21, so I added the port...
2. My login username has a literal "\" in it, believe it or not, and the FTP reply indicated name and pass required. Ultimately, I figured out it needs a double backslash to eliminate the "\" wildcard.
3. So, everything is going well now but the apparently final obstacle is weird...
550 C:\to_be_uploaded\blah.odf: The filename, directory name, or volume label syntax is incorrect
I can't figure this out as a File object is created and delete() is called on it, using the same file path string, so I think it's something funky with how FTPClient reads the file path string, maybe a backslash thing again? thank you.
The stream to the local file is already established for the second arg (fis)...so is the first arg (filename) simply the name of the file within the FTP working directory (no directory path).
I am entering the full local filepath (C:\files_to_upload\blah.pdf) for the first arg (filepath). Maybe this needs to be just "blah.pdf"?
Tommy Griffith wrote:I am entering the full local filepath (C:\files_to_upload\blah.pdf) for the first arg (filepath). Maybe this needs to be just "blah.pdf"?
You've probably figured this out already, but... When you connect to the FTP server and sign in, it will set your current directory to something which may depend on your user ID. If you want to transfer a file somewhere else, you have to use the CD command to change your current directory on the server. And if you want to transfer a file from somewhere other than your current directory on the client, you have to use the LCD command to navigate to the directory where the file is. Then you just use the file's name in the PUT command.
You might also have to change the transfer type to ASCII or BINARY to avoid having your file corrupted by the transfer process.