title: How can i upload an image to .net WebService from Android
body: <p>I'm trying to upload image to webService but I couldn't do it and I searched lots of topics on here and on the internet but could't find good solution.</p>
  
  <p>When I run this code I'm getting Bad Request error.</p>
  
  <p><strong>UPDATE</strong> : I used some codes that is in this link : <a href="https://stackoverflow.com/questions/7860298/uploading-ms-word-files-from-android-to-net-wcf">Uploading MS Word files from Android to .Net WCF?</a></p>
  
  <p>But giving me FileNotFoundException, but my file path is that : <code>/mnt/sdcard/ImageDir/images/ilan_1360917248037__thumb_.jpeg</code></p>
  
  <p>Here is my code that I'm trying :</p>
  
  <pre><code>public static String imgUpload(String url, List&lt;NameValuePair&gt; list, List&lt;String&gt; images){
  
          String result = Constants.EMPTY;
          Bitmap bm;
  
          HttpParams httpParams = new BasicHttpParams();
          HttpConnectionParams.setConnectionTimeout(httpParams, ServiceConstant.TIMEOUT_MILLISEC);
          HttpConnectionParams.setSoTimeout(httpParams, ServiceConstant.TIMEOUT_MILLISEC);
  
          HttpParams p = new BasicHttpParams();
          HttpClient httpclient = new DefaultHttpClient(p);
  
  
          HttpPost httppost = new HttpPost(url);        
  
          String resimYol = images.get(0);
          resimYol = resimYol.replace("file:///", "/");
          bm = BitmapFactory.decodeFile(resimYol);
          Log.d("RESIL_YOL", resimYol.toString());
  
  
          try{                        
  
  
              ByteArrayBody bab = new ByteArrayBody(b, resimYol);
  
  
              ResponseHandler&lt;String&gt; responseHandler = new BasicResponseHandler();  
  
              ByteArrayOutputStream bos = new ByteArrayOutputStream();
              bm.compress(CompressFormat.JPEG, 100, bos);
              byte[] data = bos.toByteArray();            
  
              ByteArrayBody bab = new ByteArrayBody(data, resimYol);
  
  
              MultipartEntity reqEntity = new MultipartEntity(HttpMultipartMode.BROWSER_COMPATIBLE);
              httppost.setEntity(reqEntity);    
          result = httpclient.execute(httppost,responseHandler);
  
          }
  
          catch (Exception e) {
                // handle exception here
                Log.e(e.getClass().getName(), e.getMessage());
              }
          return result; 
      }
  </code></pre>
  
  <p>Here is my logcat : </p>
  
  <pre><code>02-12 11:43:07.467: E/org.apache.http.client.HttpResponseException(19112): Bad Request
  </code></pre>