I have an API (created by Lumen) to save an image or file from the 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 tried the API in the postman, and everything went well, the image successfully uploaded.
What is the best way to send an image from the client side (call the API) and save the image in the API project? because my code is not working.
This is my code when you try to get the image file on the client side and then call the API.
if ($request->hasFile('image')) { $params['image'] = $request->file('image'); } $data['results'] = callAPI($method, $uri, $params);
source share