Abraham Putra Prakasa Abraham Putra Prakasa - 1 year ago 67
Android Question

Android FTP ChangeDirectory fail

I'm using ftp4j library to use FTPClient on android to upload text file from android to local network connected by Wifi.

If im not changing the directory then the default directory is


But if i try
it catches Exception "failed to change directory". I want to upload the file from External Folder Directory such as DCIM, Downloads, Bluetooth folder (Just like when you browse your android from PC).

public void uploadFile(File fileName){
FTPClient client = new FTPClient();
try {
client.login(ftpUsername, ftpPassword);
notification = "The File Has Been Uploaded";
} catch (Exception e) {
Log.e("UploadFTP", e.toString());
notification = "Upload File Failed";

try {
} catch (Exception e2) {
Log.e("UploadFTPDC", e2.toString());


Seems like I'm confused with myself, After i log the getExternalStorageDirectory() it is returning
so no need to change the directory.

Now the ftp4j Exception changed to "could not create file"

11-14 10:59:24.936: E/UploadFTP(1764): it.sauronsoftware.ftp4j.FTPException [code=553, message= Could not create file.]

Answer Source

You may have not write permission on the remote folder. Please check if the ftp user you logged in have a write permission on the directory. If not, give a write permission on it. If it unix like system try change permission like following command:

chmod +w folder