Advertisement
Guest User

Untitled

a guest
Jun 26th, 2019
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.59 KB | None | 0 0
  1. <form name="user_profile_form" id="user_profile_form" method="post" enctype="multipart/form-data">
  2. <input type="hidden" name="authorization" value="{{$authorization}}" id="authtoken"/>
  3. <input type="hidden" name="device_type" value="{{$device_type}}"/>
  4. <div class="pa-padding">
  5. <div class="pa-avatar">
  6. <img src="{{url('userprofile')}}/{{$user->profile_picture}}" alt="" width="100"
  7. height="100"
  8. id="user_profile_img">
  9. </div>
  10. <div class="pa-name">{{$user->name}}</div>
  11. <div class="pa-text">Web Developer · Designer · Team Lead</div>
  12. <br>
  13. <label for="f_upload" type="button" class="btn btn-primary m-r-10">
  14. <i class="zmdi zmdi-upload"></i> Upload profile Picture</label>
  15. <input id="f_upload" type="file" style="display: none" name="user_profile_picture"
  16. accept="image/*"/>
  17. <button type="button" id="save_user_profile">Save</button>
  18. </div>
  19. </form>
  20.  
  21.  
  22.  
  23.  
  24. <script type="text/javascript">
  25.  
  26. $("#save_user_profile").click(function (event) {
  27. event.preventDefault();
  28. var authorizationToken = $("#authtoken").val();
  29. var form = document.forms.namedItem("user_profile_form"); // high importance!, here you need change "yourformname" with
  30. var formData = new FormData(form);
  31.  
  32.  
  33. $.ajax({
  34. headers: {
  35. 'Authorization': authorizationToken,
  36. 'device_type': 'android'
  37. },
  38. async: true,
  39. type: 'post',
  40. contentType: false,
  41. cache: false,
  42.  
  43. url: '{{ action('MobileUserProfileController@updateUserProfile') }}',
  44. data: formData,
  45. processData: false,
  46. success: function (data) {
  47. var result = JSON.parse(data);
  48.  
  49. if (result.status) {
  50. alert(result.message);
  51. } else {
  52. alert(result.message);
  53. }
  54. },
  55. error: function (jqXHR, textStatus, errorThrown) {
  56. alert(errorThrown);
  57. }
  58. });
  59. });
  60.  
  61.  
  62. Android.pageParams("Profile", "", "", false, "", "", "");
  63. </script>
  64.  
  65. $userimg = $request->file('user_profile_picture');
  66. echo json_encode(['status' => true, 'message' => $_FILES]);
  67. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement