Я создаю систему в веб-просмотре, где пользователь может изменить свое изображение.
, используя ajax, laravel, webview, но она не работает, показывая следующую ошибку.profile_picture}} "alt =" "width =" 100 "height =" 100 "id =" user_profile_img "> {{$ $ user-> name}} Веб-разработчик · Дизайнер · Руководитель группы
Загрузить профиль Изображение Сохранить
<script type="text/javascript">
$("#save_user_profile").click(function (event) {
event.preventDefault();
var authorizationToken = $("#authtoken").val();
var form = document.forms.namedItem("user_profile_form"); // high importance!, here you need change "yourformname" with
var formData = new FormData(form);
$.ajax({
headers: {
'Authorization': authorizationToken,
'device_type': 'android'
},
async: true,
type: 'post',
contentType: false,
cache: false,
url: '{{ action('Mobile\UserProfileController@updateUserProfile') }}',
data: formData,
processData: false,
success: function (data) {
var result = JSON.parse(data);
if (result.status) {
alert(result.message);
} else {
alert(result.message);
}
},
error: function (jqXHR, textStatus, errorThrown) {
alert(errorThrown);
}
});
});
Android.pageParams("Profile", "", "", false, "", "", "");
</script>
это мой контроллер
public function updateUserProfile(Request $request)
{
$userimg = $request->file('user_profile_picture');
echo json_encode(['status' => true, 'message' => $_FILES]);
}
Получая следующую ошибку:
{"status":true,"message":{"user_profile_picture":{"name":"","type":"","tmp_name":"","error":4,"size":0}}}
Пожалуйста, имейте в виду, что я не использую его в браузере, он открывается в Android WebVier илиios webview или любой другой, но это будет в webview