Volley BasicNetwork.performRequest: Unexpected response code 413
<p>I'm working on a project where user registration is a small module. Where I'm taking few of the parameters like name,email, contact, age, address &amp; profile_pic.</p>

<pre><code>//Here is my Android part Code
Where Profile_pic is the compressed byte[] of an image
</code></pre>

<p>Here is my byte[] compression method</p>

<pre><code>public static byte[] compress(byte[] data) throws IOException {
    Deflater deflater = new Deflater();
    deflater.setInput(data);
    ByteArrayOutputStream outputStream = new ByteArrayOutputStream(data.length);

    deflater.finish();
    byte[] buffer = new byte[1024];
    while (!deflater.finished()) {
        int count = deflater.deflate(buffer);
        outputStream.write(buffer, 0, count);
    }
    outputStream.close();
    byte[] output = outputStream.toByteArray();

    return output;
}
</code></pre>

<p>Android Volley Reuest to store user data to the server</p>

<pre><code>public void addUser(final String name, final String email, final String mobile, final String password, final String dob,
                          final String gender, final String address, final String profile_pic, final String latLng,
                          final String city, final String state, final String country, final String postalcode) {
    StringRequest strReq = new StringRequest(Request.Method.POST,
            AppConfig.URL_REQUEST_SMS, new Response.Listener&lt;String&gt;() {

        public String addresse;

        @Override
        public void onResponse(String response) {
            System.out.println("1");

            try {
                JSONObject responseObj = new JSONObject(response);


                boolean error = responseObj.getBoolean("error");
                String message = responseObj.getString("message");
                if (!error) {
                   ......
                } else {

                    Toast.makeText(context,
                            "Error: " + message,
                            Toast.LENGTH_LONG).show();
                }


            } catch (JSONException e) {


                Toast.makeText(context,
                        "Error: " + e.getMessage(),
                        Toast.LENGTH_LONG).show();
            }

        }
    }, new Response.ErrorListener() {

        @Override
        public void onErrorResponse(VolleyError error) {

            Toast.makeText(context,
                    error.getMessage() , Toast.LENGTH_SHORT).show();
        }
    }) {

        /**
         * Passing user parameters to our server
         * @return
         */
        @Override
        protected Map&lt;String, String&gt; getParams() {
            Map&lt;String, String&gt; params = new HashMap&lt;String, String&gt;();
            params.put("name", name);
            params.put("email", email);
            params.put("mobile", mobile);
            params.put("password", password);
            params.put("dob", dob);
            params.put("gender", gender);
            params.put("address", address);
            params.put("profile_pic", profile_pic);
            params.put("latLng", latLng);
            params.put("color", String.valueOf(color));
            params.put("user_level", "patient");
            params.put("city", city);
            params.put("state", state);
            params.put("country", country);
            params.put("postalcode", postalcode);
            return checkParams(params);
        }

        private Map&lt;String, String&gt; checkParams(Map&lt;String, String&gt; map) {
            for (Map.Entry&lt;String, String&gt; pairs : map.entrySet()) {
                if (pairs.getValue() == null) {
                    map.put(pairs.getKey(), "");
                }
            }
            return map;
        }
    };

    strReq.setShouldCache(false);
    // Adding request to request queue
    AppController.getInstance().addToRequestQueue(strReq);
}
</code></pre>

<p>Here is my PHP code to upload the image</p>

<pre><code>  $file_upload_url = __DIR__."/Upload/". $target_path;
// Get file name posted from Android App
$filename = 'user_'.$name.'_Profilepic'.'.png';
//check if the directory exists
if(!file_exists($file_upload_url)){
    if(!mkdir($file_upload_url,0755,true)){
             $error = error_get_last();
                echo $error['message'];
                     echo 'failed';
          }
    }
// Decode Image
$binary=base64_decode($profile_pic);
header('Content-Type: image/png');

$file = fopen($file_upload_url.$filename, 'wb');
// Create File
fwrite($file, $binary);
fclose($file);
</code></pre>

<p>Also here is my .htaccess file settings</p>

<pre><code>php_value memory_limit 128M
php_value post_max_size 500M
php_value upload_max_filesize 500M
</code></pre>

<p>The problem with the following is that when I run the entire program in localhost it works as expected but on server I get this error from volley</p>

<pre><code>BasicNetwork.performRequest: Unexpected response code 413 
</code></pre>

<blockquote>
  <p>Solved</p>
</blockquote>

<p>The problem was with the server as it's a shared hosting the file upload limit was restricted.</p>