我正在尝试通过web api将一个图像作为化身照片上传到服务器。
任何人都可以解释如何通过当前用户id has token将图像url插入到数据中?
我已经做了
$.getJSON (url,...
我可以在任何地方阅读和附加它们。
我有这样的东西:
用户ID=1
/API/图像/上传表单/化身
/API/用户/更新用户信息
一。如何使用jquery附加图像文件并通过web api发布?
2.我怎样才能重新上传(更新)文件?
$(document).ready(function (e) {
$('#upload').on('click', function () {
var file_data = $('#file').prop('files')[0];
var form_data = new FormData();
form_data.append('file', file_data);
$.ajax({
url: 'https://myurl/api/images/upload_form/avatar', // point to server-side controller method
dataType: 'text', // what to expect back from the server
cache: false,
contentType: false,
processData: false,
data: form_data,
type: 'post',
success: function (response) {
$('#msg').html(response); // display success response from the server
},
error: function (response) {
$('#msg').html(response); // display error response from the server
}
});
});
});
用户id=1<<我需要将此键和值添加到post url,但如何添加?
任何帮助都将不胜感激。
谢谢