file upload with ftp android was connected to server but file not uploaded to server?

-1

Im trying to upload image from android to server with apache-commons-net also server file permission set to 777 the main problems is the app connect to the server but file not upload to server and return false and i use this comment to debug ftpClient.getReplyString(); And it return is Can't open that file: No such file or directory then i go to dirpath in the server and create file with format jpg empty then result return successful but I don't want to manually create that file it must create automatically and I don't know how. Can someone help me please? Thanks.

get_sharedpref_name(); return number =12345678

 class upload_class extends AsyncTask<Void, Void, Void> {

    @Override
    protected Void doInBackground(Void... voids) {

        String TAG = "MAIN_ACTIVITY";
        String server = "*******";  
        String username = "*******"; 
        String password = "*******"; 

        FTPClient ftpClient = new FTPClient();
        try {
            ftpClient.connect(server);
            ftpClient.login(username, password);
            ftpClient.enterLocalPassiveMode();
            ftpClient.setFileType(FTP.BINARY_FILE_TYPE);
            Log.d(TAG, "CONNECTED");
            String data = "/storage/emulated/0/DID/00171240341612694084230.jpg";
            String s=get_sharedpref_name();
            String dirPath ="public_html/upload_files/"+s+data;
            Log.d(TAG, String.valueOf(dirPath));
            FileInputStream in = new FileInputStream(data);
            boolean result = ftpClient.storeFile(dirPath, in);
            Log.d(TAG, String.valueOf(result));
            String ww=ftpClient.getReplyString();
            Log.d(TAG, String.valueOf(ww));
            in.close();
            if (result) Log.v(TAG, "succeeded");
            ftpClient.logout();
            ftpClient.disconnect();
            Log.d(TAG, "DISCONNECTED");
        } catch (Exception e) {
            e.printStackTrace();
        }

        return null;
    }
}

2021-02-07 17:49:42.467 18212-18212/com.example.did D/ViewRootImpl@8055841[take_pic]: ViewPostIme pointer 0
2021-02-07 17:49:42.552 18212-18212/com.example.did D/ViewRootImpl@8055841[take_pic]: ViewPostIme pointer 1
2021-02-07 17:49:42.583 18212-18454/com.example.did D/NetworkManagementSocketTagger: tagSocket(71) with statsTag=0xffffffff, statsUid=-1
2021-02-07 17:49:42.866 18212-18454/com.example.did D/MAIN_ACTIVITY: CONNECTED
2021-02-07 17:49:42.874 18212-18454/com.example.did D/MAIN_ACTIVITY: /public_html/upload_files/0017124034
2021-02-07 17:49:42.906 18212-18454/com.example.did D/NetworkManagementSocketTagger: tagSocket(78) with statsTag=0xffffffff, statsUid=-1
2021-02-07 17:49:42.985 18212-18454/com.example.did D/MAIN_ACTIVITY: false
2021-02-07 17:49:43.019 18212-18454/com.example.did D/MAIN_ACTIVITY: DISCONNECTED
2021-02-07 17:50:05.495 18212-18250/com.example.did W/com.example.di: Checksum mismatch for dex base.apk!classes2.dex
2021-02-07 17:50:05.495 18212-18250/com.example.did W/com.example.di: Could not merge the profile. Clearing the profile data.

android
ftp
upload
apache-ftpserver
asked on Stack Overflow Feb 7, 2021 by mohammad gorbani • edited Feb 7, 2021 by mohammad gorbani

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0