2017-01-24 101 views
0

嘿,我有一个android应用程序,从图库中选择一个图像,并显示在一个ImageView,我想将摄取的图像上传到我的ftp server,我尝试使用SimpleFtp库,但它只是没有工作,所以我删除它,我该怎么办?上传图像通过Android应用程序FTP服务器

这里是加载图像的代码:

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


     } 

    } 
} 
+1

“我尝试使用SimpleFtp库,但它只是没有奏效”什么都不起作用?您是否尝试调试并找出问题所在? – Egor

回答

0

与API合作的最佳方式 - Retrofit2。 尝试this

相关问题