title: Upload from camera intent
body: <p>Currenty working on small app to teach my-self. I need to capture image, show it at imageview and uploadt it. I have managed to create that intent and show image on imageview but currently can't upload it and can't figure it out how? Also have button that uploads image from gallery. Should I use Asynctask? I am lost</p>
  
  <p>Camera intent:</p>
  
  <pre><code>mCapture.setOnClickListener(new View.OnClickListener() {
          @Override
          public void onClick(View v) {
              Intent cameraIntent = new Intent (MediaStore.ACTION_IMAGE_CAPTURE);
              startActivityForResult(cameraIntent, REQUEST_CAMERA_CAPTURE);
          }
      });
  </code></pre>
  
  <p>Image upload:</p>
  
  <pre><code>private void UploadImage (){
  
      StringRequest stringRequest = new StringRequest(Request.Method.POST, UploadUrl,
              new Response.Listener&lt;String&gt;() {
                  @Override
                  public void onResponse(String response) {
  
                      try {
                          JSONObject jsonObject = new JSONObject(response);
                          String Response = jsonObject.getString("response");
                          Toast.makeText(MainActivity.this,Response,Toast.LENGTH_SHORT).show();
                          mImageView.setImageResource(0);
                          mImageView.setVisibility(View.GONE);
                          mEditText.setText("");
                          mEditText.setVisibility(View.GONE);
                      } catch (JSONException e) {
                          e.printStackTrace();
                      }
  
                  }
              }, new Response.ErrorListener() {
          @Override
          public void onErrorResponse(VolleyError error) {
  
          }
      })
  
  
      {
          @Override
          protected Map&lt;String, String&gt; getParams() throws AuthFailureError {
              Map&lt;String,String&gt; params = new HashMap&lt;&gt;();
              params.put("name1",mEditText.getText().toString().trim());
              params.put("name2", staticSpinner.getSelectedItem().toString().trim());
              params.put("image",ImageToString(bitmap));
  
              return params;
          }
      };
  </code></pre>
  
  <p>Image to string</p>
  
  <pre><code>    private String ImageToString(Bitmap bitmap){
  
      ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
      bitmap.compress(Bitmap.CompressFormat.JPEG, 25, byteArrayOutputStream);
      byte [] imgBytes = byteArrayOutputStream.toByteArray();
  
      return Base64.encodeToString(imgBytes, Base64.DEFAULT);
  }
  </code></pre>