send image in request body laravel 6

Solutions on MaxInterview for send image in request body laravel 6 by the best coders in the world

showing results for - "send image in request body laravel 6"
Aminata
19 Oct 2019
1public function uploadTest(Request $request) {
2
3    if(!$request->hasFile('image')) {
4        return response()->json(['upload_file_not_found'], 400);
5    }
6    $file = $request->file('image');
7    if(!$file->isValid()) {
8        return response()->json(['invalid_file_upload'], 400);
9    }
10    $path = public_path() . '/uploads/images/store/';
11    $file->move($path, $file->getClientOriginalName());
12    return response()->json(compact('path'));
13 }