file('file'); $file_name = $req->name; $details = $req->details; if ($req->hasFile('file')) { $extension = $file->getClientOriginalExtension(); $os = array("zip", "rar", "pdf", "doc", "docx", "txt"); if (in_array($extension, $os)){ $name = $file->getClientOriginalName(); $newFileName = $newFileName = "file_".date('d_m_y_h_m_s').".".$extension; $fileee = $file->move('assets/document/files/', $newFileName); $file_name = empty($file_name)?$name:$file_name; $cat = new FileUpload; $cat->url = $newFileName; $cat->details = $details; $cat->name = $file_name; $cat->save(); } } return redirect()->back(); } public function show($id) //use as delete { $del = FileUpload::find($id); if (File::exists('assets/document/files/'.$del->url) && !empty($del->url)) { File::delete('assets/document/files/'.$del->url); $del->delete(); } return redirect()->back(); } public function edit($id) //use for download { } public function update(Request $request, $id) { // } public function destroy($id) { // } }