Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我希望用户拥有文件选择器,然后选择一个电子表格,然后由控制器操作对其进行解析。有没有如何做到这一点的例子?
本文展示了如何在 asp.net mvc 页面上添加文件上传控件:
http://www.hanselman.com/blog/ABackToBasicsCaseStudyImplementingHTTPFileUploadWithASPNETMVCIncludingTestsAndMocks.aspx
使用这一行,您可以从请求中获取文件:
HttpPostedFile hpf = Request.Files[file] as HttpPostedFile;
得到它后,你可以用它做任何你想做的事情。