[英]Ajax file upload in laravel webview not working
I am making a system in webview where user can change their image.我正在 webview 中创建一个系统,用户可以在其中更改他们的图像。
using ajax , laravel , webview but it's not working showing following error .使用 ajax , laravel , webview 但它不起作用显示以下错误。 profile_picture}}" alt="" width="100" height="100" id="user_profile_img"> {{$user->name}} Web Developer · Designer · Team Lead
profile_picture}}" alt="" width="100" height="100" id="user_profile_img"> {{$user->name}} 网页开发者·设计师·团队负责人
Upload profile Picture Save上传个人资料图片保存
<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>
this is my controller这是我的控制器
public function updateUserProfile(Request $request)
{
$userimg = $request->file('user_profile_picture');
echo json_encode(['status' => true, 'message' => $_FILES]);
}
Getting following error :得到以下错误:
{"status":true,"message":{"user_profile_picture":{"name":"","type":"","tmp_name":"","error":4,"size":0}}}
pls keep in mind that I am not using it in browser it opening in android webvier or ios webview or any other , but this will be in webview请记住,我没有在浏览器中使用它,它是在 android webvier 或 ios webview 或任何其他浏览器中打开的,但这将在 webview 中
change改变
$userimg = $request->file('user_profile_picture');
echo json_encode(['status' => true, 'message' => $userimg]);
} }
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.