javascript 将 Excel 文件发送到 ASP.NET Web API
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/10405785/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Send Excel File to ASP.NET Web API
提问by Rivka
How do I send an excel file coming from file upload input to my ASP.NET WebAPI and then save that excel file so I can read its data?
如何将来自文件上传输入的 excel 文件发送到我的 ASP.NET WebAPI,然后保存该 excel 文件以便我可以读取其数据?
Here's what I've got (button click calls upload()) - just the basics, which works fine:
这是我所拥有的(按钮单击调用upload())-只是基础知识,效果很好:
function upload() {
$.getJSON("api/uploads/uploadfile",
function (data) {
$("#mydiv").append("Success: " + data.Success + " Failed: " + data.Failed);
});
}
And my ASP.NET WebAPI method:
我的 ASP.NET WebAPI 方法:
public DBResult UploadFile()
{
DBResult result = new DBResult();
result.Success = 0;
result.Failed = 0;
return result;
}
Any help is greatly appreciated.
任何帮助是极大的赞赏。
TIA
TIA
回答by Rivka
I was able to figure this out between these 2 articles:
我能够在这两篇文章中弄清楚这一点:
回答by Daniel Melo
I posted a similar solution at another question, but using c# to post to webapi:
How To Accept a File POST
我在另一个问题上发布了一个类似的解决方案,但使用 c# 发布到 webapi:
How To Accept a File POST