var profileImage = fileInputInByteArray;
$.ajax({
url: 'abc.com/',
type: 'POST',
dataType: 'json',
data: {
// Other data
ProfileImage: profileimage
// Other data
},
success: {
}
})
// Code in WebAPI
[HttpPost]
public HttpResponseMessage UpdateProfile([FromUri]UpdateProfileModel response) {
//...
return response;
}
public class UpdateProfileModel {
// ...
public byte[] ProfileImage {get ;set; }
// ...
}Run Code Online (Sandbox Code Playgroud)
<input type="file" id="inputFile" />Run Code Online (Sandbox Code Playgroud)
我正在使用ajax调用将输入类型=文件输入的byte []值发布到以apip []格式接收的web api.但是,我遇到了获取字节数组的困难.我希望我们可以通过File API获取字节数组.
注意:在通过ajax调用之前,我需要先将字节数组存储在变量中