title: How to pass String and File data with Volley POST method in Android?
body: <p>I am using Volley to make server requests but i came to know that volley is not passing params from getParams() method in POST request, so now i am passing these data by concatenating all param/values with the url like bellow.</p>
  
  <pre><code>String url = "http://myweb/api/work?"+param1+"="+value;
  </code></pre>
  
  <p>Now the problem is it works fine with text data only, i can make request successfully and all params are passing to server but now i have to upload some image file also using same api.</p>
  
  <p>How can i pass a file and string data using Volley POST method?</p>
  
  <p>Following are the solutions i tried but got no success.
  <a href="https://gist.github.com/anggadarkprince/a7c536da091f4b26bb4abf2f92926594#file-volleymultipartrequest-java" rel="nofollow noreferrer">https://gist.github.com/anggadarkprince/a7c536da091f4b26bb4abf2f92926594#file-volleymultipartrequest-java</a></p>
  
  <p><a href="https://www.simplifiedcoding.net/android-volley-tutorial-to-upload-image-to-server/" rel="nofollow noreferrer">https://www.simplifiedcoding.net/android-volley-tutorial-to-upload-image-to-server/</a></p>
  
  <p><strong>Edit</strong>
  Following is my current request code:</p>
  
  <pre><code>StringRequest request = new StringRequest(Request.Method.POST, uri + param, new Response.Listener&lt;String&gt;() {
          @Override
          public void onResponse(String response) {
              dismissProgressDialog();
              printResponse(response);
  
          }
      }, new Response.ErrorListener() {
          @Override
          public void onErrorResponse(VolleyError error) {
              dismissProgressDialog();
              error.printStackTrace();
  
          }
      }) {
  
          @Override
          public Map&lt;String, String&gt; getHeaders() throws AuthFailureError {
              HashMap&lt;String, String&gt; headers = new HashMap&lt;&gt;();
              headers.put("key", key);
              headers.put("tkey", tkey);
              headers.put("Content-Type", "application/multipart");
              return headers;
          }
      };
  </code></pre>