how we can show the php response from android
public class UploadImageTask extends AsyncTask<Void,Void,Void>{
String name="",path="";
@Override
protected void onPreExecute() {
super.onPreExecute();
name=product_Image_name;
path=getPath(originalUri);
Log.d("path",path+"");
Log.d("name",name+"");
Log.d("uploadurl",upload_url+"");
}
@Override
protected Void doInBackground(Void... voids) {
try{
new MultipartUploadRequest(MainActivity.this,name,upload_url)
.setMethod("POST")
.addFileToUpload(path,"uploadedfile")
.addParameter("name",name)
.setMaxRetries(2)
.startUpload();
}
catch (Exception e){
e.printStackTrace();
Log.d("error",e.getMessage());
}
return null;
}
@Override
protected void onPostExecute(Void aVoid) {
super.onPostExecute(aVoid);
clearData();
}
}
Below is my php backend
<?php
$target_path="./uploadImage/";
$target_path=$target_path.basename($_FILES['uploadedfile']['name']);
if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'],$target_path)){
echo "upladed Sucessfuly";
}
else{
echo "upladed error !";
}
?>