1public function uploadFile(Request $request) {
2 if($request->hasFile('image')) {
3 $name = time()."_".$request->file('image')->getClientOriginalName();
4 $request->file('image')->move(public_path('images'), $name);
5 }
6 return response()->json([
7 asset("images/$name"),
8 201,
9 'message' => asset("images/$name") ? 'Image saved' : 'Image failed to save'
10 ]);
11 }
12