title: how to upload image using byte array
body: <p>I'm trying to upload image using this code:</p>
  
  <pre><code>   private String uploadFile() {
   String responseString = null;
  
   try {
  
    HttpClient httpclient = new DefaultHttpClient();
    HttpPost httppost = new HttpPost(Config.FILE_UPLOAD_URL_M);
  
  
  
    Log.i("UploadApp", "upload url: " + Config.FILE_UPLOAD_URL_M);
  
  
    AndroidMultiPartEntity entity;
    entity = new AndroidMultiPartEntity(
     new AndroidMultiPartEntity.ProgressListener() {
  
      @Override
      public void transferred(long num) {
       // publishProgress((int) ((num / (float) totalSize) * 100));
      }
     });
  
    File sourceFile;
    sourceFile = new File(compressImage(filePath));
  
    Log.i("UploadApp", "file path: " + filePath);
  
    // Adding file data to http body
  
    entity.addPart("f", new FileBody(sourceFile)); //problem is here
  
  
    entity.addPart("category", new StringBody("Bill"));
    entity.addPart("description", new StringBody("test single"));
    entity.addPart("file", new StringBody("unknown1"));
    entity.addPart("clientid", new StringBody("4"));
  
  
  
    totalSize = entity.getContentLength();
    httppost.setEntity(entity);
  
    // Making server call
    HttpResponse response = httpclient.execute(httppost);
    HttpEntity r_entity = response.getEntity();
  
    int statusCode = response.getStatusLine().getStatusCode();
    if (statusCode == 200) {
     // Server response
     responseString = EntityUtils.toString(r_entity);
    } else {
     responseString = "Error occurred! Http Status Code: " + statusCode;
    }
  
   } catch (ClientProtocolException e) {
    responseString = e.toString();
    Log.e("UploadApp", "exception: " + responseString);
   } catch (IOException e) {
    responseString = e.toString();
    Log.e("UploadApp", "exception: " + responseString);
   }
  
   return responseString;
  
  }
  </code></pre>
  
  <p>I have a web service  for uploading image which has 5 parameters and 4 of them are string but one is byte array (byte[] f)</p>
  
  <p><strong>main problem:</strong> how to convert my source file(image) in byte array to upload the image on server in above code corresponding this web service.</p>