In my webservice i have simple upload function which tested by cUrl
and its work fine without any problem, and I can upload file by cUrl
successfully, now I want to upload file from android with Ion
library, but i get this error:
unable to parse json
my code is:
Ion.with(ActivityAccountInfo.this)
.load(MyApplication.getHostAddress() + "clientUploadPhoto")
.uploadProgressHandler(new ProgressCallback() {
@Override
public void onProgress(long downloaded, long total) {
uploadMessage.setText("" + downloaded + " / " + total);
}
})
.setTimeout(60 * 60 * 1000)
.setMultipartFile("userPhoto", "image/*", new File(photoPath))
.asJsonObject()
// run a callback on completion
.setCallback(new FutureCallback<JsonObject>() {
@Override
public void onCompleted(Exception e, JsonObject result) {
if (e != null) {
}
}
});
and my web function:
Route::any('clientUploadPhoto', function () {
$filename = Request()->file('userPhoto');
$destinationPath = base_path() . '/upload/';
$new_filename = time() . '_' . $filename->getClientOriginalName();
Image::make($filename->getRealPath())->save($destinationPath . $new_filename);
});