Well this might sound a question that has been asked few often times but I could not come with a solution for the same.I want to upload image to server C#, i got codes for how to send image but don't know exactly how to use it. Please correct my code if there is something wrong and any idea about server side code for the same correction.
ProgressDialog progressDialog = new ProgressDialog(AddPropertyThird.this);
progressDialog.setMessage("Uploading, please wait...");
progressDialog.show();
//converting image to base64 string
ByteArrayOutputStream baos = new ByteArrayOutputStream();
bitmap.compress(Bitmap.CompressFormat.JPEG, 100, baos);
byte[] imageBytes = baos.toByteArray();
final String imageString = Base64.encodeToString(imageBytes,Base64.DEFAULT);
//sending image to server
StringRequest request = new StringRequest(Request.Method.POST, URL, new Response.Listener<String>() {
@Override
public void onResponse(String s) {
progressDialog.dismiss();
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError volleyError) {
Toast.makeText(AddPropertyThird.this, "Some error occurred -> " + volleyError, Toast.LENGTH_LONG).show();
}
}) {
//adding parameters to send
@Override
protected Map<String, String> getParams() throws AuthFailureError {
Map<String, String> parameters = new HashMap<String, String>();
parameters.put("imageFile", imageString);
return parameters;
}
};
RequestQueue rQueue = Volley.newRequestQueue(AddPropertyThird.this);
rQueue.add(request);
}
});
}
Logcat error
[879] BasicNetwork.performRequest: Unexpected response code 500
02-09 12:33:24.106 2 E/volleyerror: com.android.volley.ServerError