SHARE
TWEET

Untitled

a guest Jun 20th, 2019 54 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. $(document).ready(function () {
  2.  
  3. $('#updateUser').click(function(){
  4.  
  5.     var form = $('#updateForm');
  6.  
  7.     var postData = new FormData($("#updateForm")[0]);
  8.  
  9.  
  10.     $.ajax({
  11.         headers: {
  12.             'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
  13.         },
  14.         cache : false,
  15.         contentType: false,
  16.         processData: false,
  17.         url: form.attr('action'),
  18.         type: form.attr('method'),
  19.         dataType: 'json',
  20.         data: postData,
  21.         success : function(response){
  22.             console.log(response);
  23.         }
  24.     });
  25.  
  26.  
  27. })
  28.      
  29. <form id="updateForm" class="ui form register-form"  method="POST" action="{{ route('updateUserProfile') }}" enctype="multipart/form-data">
  30.                     @csrf
  31.  
  32.                     <div class="field">
  33.                         <label>Profile Photo</label>
  34.                         <div class="two fields">
  35.                             <div class="field">
  36.                                 <img src="{{ $current_user->profile_photo }}">
  37.                             </div>
  38.                             <div class="field">
  39.                                 <input type="file" name="profile_photo" placeholder="Profile Photo" class="" multiple="">
  40.                             </div>
  41.                         </div>
  42.  
  43.                     </div>
  44.      
  45. namespace AppHttpControllersAuth;
  46. use Auth;
  47. use AppFunctions;
  48. use IlluminateHttpRequest;
  49. use AppHttpControllersController;
  50. use IlluminateSupportFacadesValidator;
  51. use IlluminateHttpFile;
  52. use IlluminateHttpUploadedFile;
  53. use IlluminateSupportFacadesInput;
  54.  
  55.  
  56. public function updateUserProfile(Request $request)
  57.  
  58. {
  59.     $validators = Validator::make($request->all(), [
  60.         'first_name' => ['required', 'string', 'max:255'],
  61.         'last_name' => ['required', 'string', 'max:255'],
  62.         'email' => ['required', 'string', 'email', 'max:255'],
  63.         'password' => ['required', 'string', 'min:8', 'confirmed'],
  64.         'mobile_no' => ['required', 'string', 'max:255'],
  65.         'dob' => ['required', 'string', 'max:255'],
  66.         'gender' => ['required', 'string', 'max:255'],
  67.         'country_id' => ['required', 'string', 'max:255'],
  68.         //'profile_photo' => ['image', 'mime_content_type(jpeg,png,jpg,gif,svg)', 'max:1024'],
  69.         'profile_photo' => 'image'|'mimes:jpg,jpeg,png',
  70.     ]);
  71.  
  72.     if ($validators->fails()) {
  73.         $result['success'] = false;
  74.         $result['messages'] = $validators->errors()->all();
  75.  
  76.         return json_encode($result);
  77.     }
  78.  
  79.     var_dump(input::file('profile_photo'));
  80.     var_dump($request->hasFile('profile_photo'));
  81.  
  82. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top