1 回答

TA貢獻(xiàn)2021條經(jīng)驗(yàn) 獲得超8個(gè)贊
這是一個(gè)基本示例。你應(yīng)該使用FormData
var formData = new FormData();
var uploadFiles = document.getElementById('js-upload-files').files;
this.formData.append("MyKey", uploadFiles[0]);
$.ajax({
type: "POST",
url: 'Controller/Upload',
data: formData,
dataType: 'json',
contentType: false,
processData: false,
complete: this.onComplete.bind(this)
});
編輯
忘記控制器代碼
[HttpPost]
public virtual BetterJsonResult Upload()
{
foreach (var fileKey in Request.Files)
{
...Request.Files[fileKey.ToString()] //access it like this
}
}
- 1 回答
- 0 關(guān)注
- 133 瀏覽
添加回答
舉報(bào)