简体   繁体   English

asp.net mvc上传文件ajax

[英]asp.net mvc Upload File ajax

Hi ive got an mvc form with a fileupload functionality. 嗨我有一个带文件上传功能的mvc表单。 Ive got an action that accepts an file and extracts thumbnails from it, after which the user can select the images and then proceed to submit the form. 我有一个接受文件并从中提取缩略图的动作,之后用户可以选择图像,然后继续提交表格。 How can post the initial file via ajax, bearing in mind, this is not the final submission on the form and I want to retain user input. 如何通过ajax发布初始文件,请记住,这不是表单上的最终提交,我想保留用户输入。 ie no postback Thanks 即没有回发谢谢

I use the ajaxupload plugin for jQuery. 我为jQuery使用ajaxupload插件。 Lots of sample code is provided on the site. 网站上提供了大量示例代码。 From the site: 从网站:

[The] plugin creates invisible file input on top of the button you provide, so when user clicks on your button the normal file selection window is shown. []插件在您提供的按钮顶部创建不可见的文件输入,因此当用户单击您的按钮时,将显示正常的文件选择窗口。 And after user selects a file, plugin submits form that contains file input to an iframe. 用户选择文件后,插件会将包含文件输入的表单提交给iframe。 So it isn't true ajax upload, but brings same user experience. 所以它不是真正的ajax上传,但带来相同的用户体验。

Browsers don't allow the uploading of files via ajax. 浏览器不允许通过ajax上传文件。 There are several good workarounds , however. 但是,有几个很好的解决方法

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM