I am trying to upload a picture from a Samsung to an FTP server using the Apache FTPClient
. But it does not seem to work. I don't know why, the code is fine. I am trying to choose an image to upload it on the server, the selectedImage
variable is the complete path of the picture file.
FTPClient ftpClient = new FTPClient();
ftpClient.connect(InetAddress.getByName("ftpserver"));
ftpClient.login("user", "password");
ftpClient.setFileType(FTP.BINARY_FILE_TYPE);
FileInputStream buffIn = null;
buffIn = new FileInputStream(new File(getRealPathFromURI(selectedImage)));
ftpClient.enterLocalPassiveMode();
link = "http://ftpname/home/user/public_html/image/ayri.jpg";
ftpClient.storeFile(link, buffIn);
buffIn.close();
ftpClient.logout();
ftpClient.disconnect();