i am creating a method that should upload a file to an api.the method isn't uploading the file into the specific folder.and upon testing on postman i get a 200 ok status code but the file isn't uploaded on sending it at postman.
this is the method in the imagecontroller
public function pushimage(Request $request)
{
$file=$request->file('image');
if($request->hasFile('image')){
$extension = $file->getClientOriginalExtension();
$newimage=rand() . '.' . $extension;
$file->move(public_path() . ("/images/product/fileimage/"), $newimage);
return response()->json($newimage);
}else{
return response()->json('file not found');
}
}
this is the api route
Route::post('/push_image','imagecontroller@pushimage');
upon uploading the file in the body section in postman it returns the response of "file not found". i havent understood what am doing it wrong to prevent the execution of the function.