I'm into developing an mobile app using Cordova and I'm using Laravel Lumen as my API server and my mobile app has this part where you browse picture, edit it with third party image editor plugin then it will output a base64, then I convert it to blob then use the FormData()
to send it to my Lumen API server, I can confirm the file by $_FILES['avatar']
or even by using Laravel Storage
Storage::putFile('avatars', '');
and upon var dump, it returns
after that I use, Guzzle to send the received file from the Lumen API server to another PHP server (Codeigniter)
$data = [];
foreach( $request->input() as $key => $val){
$data[] = [
'name' => $key,
'contents' => $val
];
} // append the extra datas first
$data[] = [
'name' => 'avatar',
'contents' => ( isset( $_FILES['avatar'] ) ) ? $_FILES['avatar'] : false
]; // append the file
// send to another server
$res = $this->client->request('POST','https://myapiserver.com/api/update/profile',
[
'multipart' => $data
]
);
return response()->json(json_decode($res->getBody()->getContents()));
Unfortunately, below image is the returned error. Any help, ideas please?