Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $(document).ready(function () {
- $('#updateUser').click(function(){
- var form = $('#updateForm');
- var postData = new FormData($("#updateForm")[0]);
- $.ajax({
- headers: {
- 'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
- },
- cache : false,
- contentType: false,
- processData: false,
- url: form.attr('action'),
- type: form.attr('method'),
- dataType: 'json',
- data: postData,
- success : function(response){
- console.log(response);
- }
- });
- })
- <form id="updateForm" class="ui form register-form" method="POST" action="{{ route('updateUserProfile') }}" enctype="multipart/form-data">
- @csrf
- <div class="field">
- <label>Profile Photo</label>
- <div class="two fields">
- <div class="field">
- <img src="{{ $current_user->profile_photo }}">
- </div>
- <div class="field">
- <input type="file" name="profile_photo" placeholder="Profile Photo" class="" multiple="">
- </div>
- </div>
- </div>
- namespace AppHttpControllersAuth;
- use Auth;
- use AppFunctions;
- use IlluminateHttpRequest;
- use AppHttpControllersController;
- use IlluminateSupportFacadesValidator;
- use IlluminateHttpFile;
- use IlluminateHttpUploadedFile;
- use IlluminateSupportFacadesInput;
- public function updateUserProfile(Request $request)
- {
- $validators = Validator::make($request->all(), [
- 'first_name' => ['required', 'string', 'max:255'],
- 'last_name' => ['required', 'string', 'max:255'],
- 'email' => ['required', 'string', 'email', 'max:255'],
- 'password' => ['required', 'string', 'min:8', 'confirmed'],
- 'mobile_no' => ['required', 'string', 'max:255'],
- 'dob' => ['required', 'string', 'max:255'],
- 'gender' => ['required', 'string', 'max:255'],
- 'country_id' => ['required', 'string', 'max:255'],
- //'profile_photo' => ['image', 'mime_content_type(jpeg,png,jpg,gif,svg)', 'max:1024'],
- 'profile_photo' => 'image'|'mimes:jpg,jpeg,png',
- ]);
- if ($validators->fails()) {
- $result['success'] = false;
- $result['messages'] = $validators->errors()->all();
- return json_encode($result);
- }
- var_dump(input::file('profile_photo'));
- var_dump($request->hasFile('profile_photo'));
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement