react native image picker sending uri string laravel php code example

Example 1: send image in request body laravel 6

public function uploadTest(Request $request) {

    if(!$request->hasFile('image')) {
        return response()->json(['upload_file_not_found'], 400);
    }
    $file = $request->file('image');
    if(!$file->isValid()) {
        return response()->json(['invalid_file_upload'], 400);
    }
    $path = public_path() . '/uploads/images/store/';
    $file->move($path, $file->getClientOriginalName());
    return response()->json(compact('path'));
 }

Example 2: laravel request img

//esto va el request rules();
//solo permitira las extenciones: jpeg,png,jpg,gif,svg
'input_img' => 'required|image|mimes:jpeg,png,jpg,gif,svg|max:2048',

Tags:

Php Example