I am using Apache FTPClient and FTPServer libraries in my Java project. Server and client are on the same machine.
My FTPServer should be a local server, not connected to the Internet. I can connect to FTPServer from the client (I get 230 as the response code), but I can not do anything. I cannot store or retrieve any files.
I read almost every question related to this question, but people who asked other questions could send simple files and had problems sending files like pdf, etc. I just need to send or receive text files.
Any suggestions?
FTPClient client = new FTPClient(); String host = "mypc"; String Name = "user"; String Pass = "12345"; client.connect(host); client.login(Name,Pass); System.out.println("Reply Code: " +client.getReplyCode()); File file = new File("C:\\.....myfile..txt"); FileInputStream in = new FileInputStream("C:\\.....myfile..txt"); boolean isStored = client.storeFile("uploadedfile.txt", in); in.close(); client.logout(); System.out.println("isStored: " +isStored);
I did not specify real path names. It returns false, no exceptions, etc. Could this be because they are on the same machine?
Edit: It turned out that I needed write permission to send the file to ftpserver. By default, it does not give users write permission. How can I grant users the right to write using the apache appserver library?
toruko
source share