Sending images and videos to server in android

前端 未结 3 698
走了就别回头了
走了就别回头了 2021-01-01 05:22

I am creating an android application for taking photos and videos. After capture images I want to send this image with date and some text to web server. In server side I am

3条回答
  •  粉色の甜心
    2021-01-01 05:59

    You can use this code in your asynctask:

    File file = new File("Your File path on SD card");
    HttpClient httpclient = new DefaultHttpClient();
    HttpPost httpost = new HttpPost("YourUrl");
    
    MultipartEntity entity = new MultipartEntity();
    entity.addPart("YourKey",new StringBody("Your Text"));
    entity.addPart("File", new FileBody(file));
    httpost.setEntity(entity);
    
    
    HttpResponse response = httpclient.execute(httpost);
    

提交回复
热议问题