Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- validation :
- $validator = Validator::make($request->all(), [
- 'complianeFor' => 'required'
- ]);
- if ($validator->fails()) {
- return redirect('/CaseCreate')
- ->withErrors($validator)
- ->withInput();
- }
- $allowedfileExtension=['pdf','jpg','png','docx','doc','mp4','mp3'];
- if(count($request->file('support_doc')) != 0){
- $files = $request->file('support_doc');
- foreach($files as $file){
- $filename = $file->getClientOriginalName();
- $extension = $file->getClientOriginalExtension();
- $check=in_array($extension,$allowedfileExtension);
- }
- }
- if($check == false){
- Session::flash('message', 'You file format does not supported. Please upload pdf,jpg,png,docx,doc formated file!');
- return redirect('/CaseCreate');
- }
- if($_FILES['support_doc']['size'] > 10000){
- Session::flash('message', 'Please upload file less than 10 mb');
- return redirect('/CaseCreate');
- }
- else {
- $compliance = new BlastApplication();
- $tracking_no = date('ymdhis');
- insert data
- ____________________________________________
- upload data :
- $file = $request['support_doc'];
- $compliancesupportingdoc = new ComplianceSupportingDoc();
- if(!empty($file)){
- $doc = [];
- foreach($file as $files){
- $filename = $files->getClientOriginalName();
- $orginal_name = pathinfo($filename, PATHINFO_FILENAME);
- $imageName = md5(time().$orginal_name).'.'.$files->getClientOriginalExtension();
- $files->move(public_path('ComplianceDoc'), $imageName);
- $doc[] = [
- 'caseId' => $compliance->case_id,
- 'tracking_no' => $tracking_no,
- 'orginal_name' => $orginal_name,
- 'supporting_doc_name' => $imageName
- ];
- }
- DB::table('compliance_supporting_docs')->insert($doc);
Add Comment
Please, Sign In to add comment