2011-10-12 28 views
3

我使用如何使用FTPClient将图像上传到FTP?

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(); 
} 

随着它工作的文本文件。随着图像文件,图像很奇怪:

image

如何纠正它吗?

+1

哪一个FTP库您使用?尝试以二进制模式传输图像。 – Farhan

+0

Common Apache 3.0.1 – J3n

回答