I am sending image to server using HTTPUrlConnection. How to write php code to receive image and send response without json. Could you please explain how php will receive file data without json structure.
public void uploadFile(String sourceFileUri, String upLoadServerUri) {
URL url=null;
HttpURLConnection connection = null;
Bitmap bm = BitmapFactory.decodeFile(sourceFileUri);
ByteArrayOutputStream bao = new ByteArrayOutputStream();
bm.compress(Bitmap.CompressFormat.JPEG, 10, bao);
try {
//Create connection
url = new URL(upLoadServerUri);
connection = (HttpURLConnection) url.openConnection();
connection.setRequestMethod("POST");
connection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
connection.setRequestProperty("Content-Language", "en-US");
connection.setUseCaches(false);
connection.setDoInput(true);
connection.setDoOutput(true);
//Send request
DataOutputStream writer = new DataOutputStream(connection.getOutputStream());
writer.writeBytes(bao.toString());
writer.flush();
writer.close();
//Get Response
InputStream is = connection.getInputStream();
BufferedReader rd = new BufferedReader(new InputStreamReader(is));
String line;
StringBuffer response = new StringBuffer();
while ((line = rd.readLine()) != null) {
response.append(line);
response.append('\r');
}
rd.close();
} catch (Exception e) {
e.printStackTrace();
return null;
} finally {
if (connection != null) {
connection.disconnect();
}
}
}