通过Ajax上传文件至WebApi服务器

https://stackoverflow.com/questions/43013858/ajax-post-a-file-from-a-form-with-axios

var formData = new FormData();

var imagefile = document.querySelector('#file');

formData.append("stuff", "some information");

formData.append("file", imagefile.files[0]);

axios.post('upload_file', formData, {

headers: {

'Content-Type': 'multipart/form-data'

}

})

服务器端接收:https://stackoverflow.com/questions/10320232/how-to-accept-a-file-post 

https://docs.microsoft.com/en-us/aspnet/web-api/overview/advanced/sending-html-form-data-part-2

https://stackoverflow.com/questions/37414415/uploading-a-file-and-form-data-in-web-api-and-angularjs

posted @ 2017-08-21 09:13  队长  阅读(912)  评论(0编辑  收藏  举报