2011-10-12 27 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

回答