This is my php laravel code to change/upload image. I want to upload file from android device. I have server side code only. how to send file from android???
//change org logo
public function change_orgLogo() {
$input = Input::all();
$file = Input::file('file');
if ($file) {
$destinationPath = 'images/org_logo/'.Input::get('org_id').'/';
$filename = $file->getClientOriginalName();
$upload_success = Input::file('file')->move($destinationPath, $filename);
$picUrl = 'images/org_logo/'.Input::get('org_id').'/'.$filename;
} else {
$picUrl = Organizationinfo::where("id", Input::get('org_id'))->pluck("logo");
$upload_success = true;
}
if (Input::get('company_name') != null && Input::get('company_name') != "") {
$cmpName = Input::get('company_name');
} else {
$cmpName = Organizationinfo::where("id", Input::get('org_id'))->pluck("name");
}
if ($upload_success) {
$res = Organizationinfo::where('id', Input::get('org_id'))->update(['logo' => $picUrl, 'name' => $cmpName]);
if ($res)
return Redirect::back()->with('Changes saved successfully');
else
return Redirect::back()->with('Error while changing image');
} else {
return Redirect::back()->with('Error while changing image');
}
}
This is my client side code to post request to server.
//edit org info
private class EditOrgInfo extends RemoteDataExporter {
String choice;
public EditOrgInfo(Context appContext) {
super(editOrgURL, UserManagementActivity.this);
this.choice = choice;
}
@Override
HashMap<String, String> buildMapFromValue() {
HashMap<String, String> maps = new HashMap<String, String>();
maps.put(TAG_NAME, edt_org_name.getText().toString());
return maps;
}
@Override
void processPostExecute() {
}
}