相关疑难解决方法(0)

通过input type = file获取字节数组

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调用之前,我需要先将字节数组存储在变量中

html javascript html5 fileapi

21
推荐指数
4
解决办法
11万
查看次数

标签 统计

fileapi ×1

html ×1

html5 ×1

javascript ×1