I have an API (created by Lumen) to save an image or file from client side.
this is my API code
if ($request->hasFile('image')) {
$image = $request->file('image');
$fileName = $image->getClientOriginalName();
$destinationPath = base_path() . '/public/uploads/images/product/' . $fileName;
$image->move($destinationPath, $fileName);
$attributes['image'] = $fileName;
}
I already try the API in postman, and everything went well, image sucessfully uploaded.
What's the best practice to send image from client side (call the API), and save the image in the API project ? because my code isn't working..
This is my code when try to receive image file in client side, and then call the API.
if ($request->hasFile('image')) {
$params['image'] = $request->file('image');
}
$data['results'] = callAPI($method, $uri, $params);