Guest User

Untitled

a guest
Jul 22nd, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.22 KB | None | 0 0
  1. validation :
  2.  
  3. $validator = Validator::make($request->all(), [
  4.  
  5. 'complianeFor' => 'required'
  6.  
  7. ]);
  8. if ($validator->fails()) {
  9. return redirect('/CaseCreate')
  10. ->withErrors($validator)
  11. ->withInput();
  12. }
  13.  
  14. $allowedfileExtension=['pdf','jpg','png','docx','doc','mp4','mp3'];
  15. if(count($request->file('support_doc')) != 0){
  16. $files = $request->file('support_doc');
  17. foreach($files as $file){
  18. $filename = $file->getClientOriginalName();
  19. $extension = $file->getClientOriginalExtension();
  20. $check=in_array($extension,$allowedfileExtension);
  21. }
  22. }
  23. if($check == false){
  24. Session::flash('message', 'You file format does not supported. Please upload pdf,jpg,png,docx,doc formated file!');
  25. return redirect('/CaseCreate');
  26. }
  27. if($_FILES['support_doc']['size'] > 10000){
  28. Session::flash('message', 'Please upload file less than 10 mb');
  29. return redirect('/CaseCreate');
  30. }
  31. else {
  32. $compliance = new BlastApplication();
  33. $tracking_no = date('ymdhis');
  34. insert data
  35.  
  36.  
  37.  
  38. ____________________________________________
  39.  
  40.  
  41. upload data :
  42.  
  43. $file = $request['support_doc'];
  44. $compliancesupportingdoc = new ComplianceSupportingDoc();
  45. if(!empty($file)){
  46. $doc = [];
  47. foreach($file as $files){
  48. $filename = $files->getClientOriginalName();
  49. $orginal_name = pathinfo($filename, PATHINFO_FILENAME);
  50. $imageName = md5(time().$orginal_name).'.'.$files->getClientOriginalExtension();
  51. $files->move(public_path('ComplianceDoc'), $imageName);
  52. $doc[] = [
  53. 'caseId' => $compliance->case_id,
  54. 'tracking_no' => $tracking_no,
  55. 'orginal_name' => $orginal_name,
  56. 'supporting_doc_name' => $imageName
  57. ];
  58. }
  59. DB::table('compliance_supporting_docs')->insert($doc);
Add Comment
Please, Sign In to add comment