1$validate = Validator::make($params = $request->all(), [
2 'type' => 'required',
3 'files' => 'mimes:jpeg,png,jpg,svg,doc,docx,odt,pdf,tex,txt,wpd,tiff,tif,csv,psd,key,odp,pps,ppt,pptx,ods,xls,xlsm,xlsx'
4]);
1$document = $request->upload_file;
2if ($document) {
3 $validate = Validator::make(
4 [
5 'extension' => strtolower($request->upload_file->getClientOriginalExtension()),
6 ],
7 [
8 'extension' => 'in:jpg,jpeg,png,gif,pdf,csv,docx,xlsx,txt',
9 ]
10 );
11 if ($validate->fails())
12 return redirect()->back()->withErrors($validator->errors());
13
14 $fileName = $document->getClientOriginalName();
15 $document->move('public/documents', $fileName);
16 $data['upload_file'] = $fileName;
17}