Android 如何使用FTPClient将图像上载到FTP?

Android 如何使用FTPClient将图像上载到FTP?,android,image,ftp,Android,Image,Ftp,我正在使用 FTPClient con = new FTPClient(); try { con.connect(HOST); if (con.login (LOGIN, PASSWORD)) { con.enterLocalPassiveMode(); InputStream instream = context.openFileInput(filename); con.storeFile(filename, instr

我正在使用

FTPClient con = new FTPClient();
try
{
    con.connect(HOST);
    if (con.login (LOGIN, PASSWORD))
    {
        con.enterLocalPassiveMode(); 
        InputStream instream = context.openFileInput(filename);
        con.storeFile(filename, instream);
        instream.close();
    }
}
catch (Exception e)
{
    e.printStackTrace();
}
try
{
    con.logout();
    con.disconnect();
}
用一个文本文件就可以了。对于图像文件,图像非常奇怪:


如何更正?

尝试更改文件类型:

con.setFileType(FTP.BINARY_FILE_TYPE)

您正在使用哪个ftp库?尝试以二进制模式传输图像。