title: Android: How to send song file to server throught HttpPost along with other variables
body: <p>I am to send a song file to server through HttpPost. Currently I am using this code to send data to server </p>
  
  <pre><code>HttpPost postRequest = new HttpPost();
          try {
  
              List&lt;NameValuePair&gt; nameValuePairs = new ArrayList&lt;NameValuePair&gt;(2);
              nameValuePairs.add(new BasicNameValuePair("email",  Splash.pref.getString("userEmail", "")));
              nameValuePairs.add(new BasicNameValuePair("password", Splash.pref.getString("userPassword", "")));
  
              nameValuePairs.add(new BasicNameValuePair("name", etName.getText().toString()));
              nameValuePairs.add(new BasicNameValuePair("title", ttfSongTitle.getText().toString()));
  
              postRequest.setEntity(new UrlEncodedFormEntity(nameValuePairs));
  
              // construct a URI objectedsta
              postRequest.setURI(new URI(serviceURL));
          } catch (URISyntaxException e) {
              Log.e("URISyntaxException", e.toString());
          }
  </code></pre>
  
  <p>But to send song file to server I have find this code on net but having problems to integrate these both.</p>
  
  <pre><code>String url = "http://yourserver";
  File file = new File(Environment.getExternalStorageDirectory(),
          "yourfile");
  try {
      HttpClient httpclient = new DefaultHttpClient();
  
      HttpPost httppost = new HttpPost(url);
  
      InputStreamEntity reqEntity = new InputStreamEntity(
              new FileInputStream(file), -1);
      reqEntity.setContentType("binary/octet-stream");
      reqEntity.setChunked(true); // Send in multiple parts if needed
      httppost.setEntity(reqEntity);
      HttpResponse response = httpclient.execute(httppost);
      //Do something with response...
  
  } catch (Exception e) {
      // show error
  }
  </code></pre>
  
  <p>Please help me so that I could integrate these both or some other solution, so that I could send Music file to server along with other authentication data.</p>
  
  <p>I am sending data to server through secure restful service.</p>
  
  <p>thanks.</p>