How to get the name of the file in the database 'img' as $ fileName? in place of this in my database, the file name is indicated as pathname, like this "C: \ wamp64 \ tmp \ php709A.tmp"
function store(Request $request){ $this->validate($request, ['title'=>'required|max:255', 'desc'=>'required', 'price'=>'required', 'img'=>'required']); $fileName = null; if (request()->hasFile('img')) { $file = request()->file('img'); $fileName = md5($file->getClientOriginalName() . time()) . "." . $file->getClientOriginalExtension(); $file->move('img', $fileName); } $data = $request->all(); $product = new Product; $product->fill($data); $product->save(); dump($data); }