Our Products:   CompleteFTP  edtFTPnet/Free  edtFTPnet/PRO  edtFTPj/Free  edtFTPj/PRO
0 votes
6.5k views
in Java FTP by
I receive this log message:

The FTP client has not yet connected to the server. The requested action cannot be performed until after a connection has been established.

When attempting to set Binary transfer after login. No other errors or log entries are sent.

code:
  public String uploadFile() {
        try {
           FTPClient ftp = new FTPClient();
           
           ftp.setRemoteHost(dest[s]);
           
            ftp.login(user[s],pass[s]);
            
            ftp.setType(FTPTransferType.BINARY);
            
            ftp.chdir(destfolder[s]);
            
            ftp.put(localfolder[s]+filename[s],filename[s]);
            
            ftp.quit();
        } catch(Exception e){
            System.out.println( e.getMessage());
            return localfolder[s]+filename[s]+" failed.";
        }
        return filename[s]+" uploaded.";
    }

2 Answers

0 votes
by
You need to call FTPClient.connect() before calling FTPClient.login().
0 votes
by
It turns out we recently updated our edt jar from v.1.3.8 on this machine and this must be a newer way of connecting since the same code works elsewhere.

Bill

- what a great package, BTW.

Categories

...