0

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.on the 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.

VLAZ
  • 26,331
  • 9
  • 49
  • 67
stephen Weru
  • 97
  • 12

1 Answers1

0

i had forgotten to tick this button here correct answer in postman.also add the boundary and define it

stephen Weru
  • 97
  • 12
  • As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Mar 04 '22 at 09:37