Advertisement
Guest User

Untitled

a guest
Jun 26th, 2019
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.63 KB | None | 0 0
  1. <script type="text/javascript">
  2.  
  3. $("#save_user_profile").click(function (event) {
  4. event.preventDefault();
  5. var authorizationToken = $("#authtoken").val();
  6. var form = document.forms.namedItem("user_profile_form"); // high importance!, here you need change "yourformname" with
  7. var formData = new FormData(form);
  8.  
  9.  
  10. $.ajax({
  11. headers: {
  12. 'Authorization': authorizationToken,
  13. 'device_type': 'android'
  14. },
  15. async: true,
  16. type: 'post',
  17. contentType: false,
  18. cache: false,
  19.  
  20. url: '{{ action('MobileUserProfileController@updateUserProfile') }}',
  21. data: formData,
  22. processData: false,
  23. success: function (data) {
  24. var result = JSON.parse(data);
  25.  
  26. if (result.status) {
  27. alert(result.message);
  28. } else {
  29. alert(result.message);
  30. }
  31. },
  32. error: function (jqXHR, textStatus, errorThrown) {
  33. alert(errorThrown);
  34. }
  35. });
  36. });
  37.  
  38.  
  39. Android.pageParams("Profile", "", "", false, "", "", "");
  40. </script>
  41.  
  42. public function updateUserProfile(Request $request)
  43. {
  44.  
  45. $userimg = $request->file('user_profile_picture');
  46. echo json_encode(['status' => true, 'message' => $_FILES]);
  47. }
  48.  
  49. {"status":true,"message":{"user_profile_picture":{"name":"","type":"","tmp_name":"","error":4,"size":0}}}
  50.  
  51. $userimg = $request->file('user_profile_picture');
  52. echo json_encode(['status' => true, 'message' => $userimg]);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement