[英]Upload image to an ftp server through android app
嘿,我有一个android
应用程序,可以从图库中选择图像并将其显示在ImageView
,我想将选择的图像上传到我的ftp server
,我尝试使用SimpleFtp
库,但是它没有用,所以我删除了它,如何可以吗
这是加载图像的代码:
public void loadImage(View view)
{
loadedImage = (ImageView)findViewById(R.id.upload_image1);
Drawable drawable = loadedImage.getDrawable();
if(drawable.getConstantState().equals(getResources().getDrawable(R.drawable.camera_icon).getConstantState())) {
Intent intent = new Intent();
intent.setType("image/*");
intent.setAction(Intent.ACTION_GET_CONTENT);
startActivityForResult(Intent.createChooser(intent, "SelectPicture"), SELECT_PICTURE);
}
else
{
Intent i = new Intent(this, ShowImage.class);
i.putExtra("uri",selectedImageURI.toString());
startActivity(i);
}
}
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
if (resultCode == RESULT_OK) {
if (requestCode == SELECT_PICTURE) {
selectedImageURI = data.getData();
loadedImage = (ImageView)findViewById(R.id.upload_image1);
loadedImage.setScaleType(ImageView.ScaleType.CENTER_CROP);
Glide.with(this).load(selectedImageURI)
.into((ImageView) findViewById(R.id.upload_image1));
}
}
}
使用api的最佳方法-Retrofit2。 试试这个
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.