【发布时间】:2014-05-15 15:14:37
【问题描述】:
我按照一本手册将图像从 Android 上传到 FTP。如果我尝试更新已拍摄的照片,我在 FTP 文件上看不到任何内容。它创建并且大小还可以,但不包含任何内容。然后我尝试上传一张小图片,结果如下:
(随机图片上传)
(图片上传)
代码:`class Sender extends AsyncTask { 档案照片; 公共发件人(档案照片){ this.photo=照片;
}
protected String doInBackground(String... params)
{
FTPClient ftpClient = new FTPClient();
try {
ftpClient.connect(InetAddress.getByName("ftp.fercode.com"));
ftpClient.login(xxx","xxx");
Boolean result = ftpClient.changeWorkingDirectory("/img");
Log.e("existeix carpeta?",result.toString() );
} catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
InputStream srcFileStream=null;
try {
srcFileStream = new FileInputStream(photo.getAbsolutePath());
} catch (FileNotFoundException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
try {
//ftpClient.stor(photo.getAbsolutePath());
boolean status = ftpClient.storeFile("/img/imagePrueba.jpeg",
srcFileStream);
Log.e("Status", String.valueOf(status));
srcFileStream.close();
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
// TODO Auto-generated method stub
return null;
}
@Override
protected void onPreExecute()
{
super.onPreExecute();
}
@Override
protected void onPostExecute(String result)
{
// TODO Auto-generated method stub
super.onPostExecute(result);
}
}`
我做错了什么?非常感谢
【问题讨论】: