Advertisement
Guest User

Untitled

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