validate([ 'file' => ['required', 'file', 'image', 'mimes:jpg,jpeg,png,gif,webp', 'max:5120'], ]); $path = $request->file('file')->store('uploads/' . date('Y/m'), 'public'); return response()->json([ 'url' => Storage::disk('public')->url($path), 'path' => $path, ]); } }