File uploading in AJAX updatepanel without full postback

血红的双手。 提交于 2019-11-27 03:41:39

For solve this problem, Please see the following step.

  1. Add ajax-upload to your detail view.
    • iframe-based uploader like Resource#1.
    • Silverlight-based & Flash-based uploader. I like this technique because it doesn't require any server-side script for display current upload status. But in HTML5, you can create this without using any web browser plug-in.
    • Commercial uploader like Resource#2. that use hidden iframe for uploading.
  2. Upload file to temporary location.

    • System response the temporary location. Next, client keep temporary location in hidden input in detail form.
    • Keep temporary location with session_id. You can store it in database or Session variable depend on your framework.
  3. When you click on the save button, the system will move the files to their real location

Note. System will automatically delete the expired file from the temporary location.

Resource

  1. ASP.NET File Upload with Real-Time Progress Bar
  2. ASP.NET File Upload like GMail (Commercial)

Update

After almost one year, I just found a great 3rd-parties control for this question. This is an open source plug-in of jQuery. It name Plupload that allows you to upload files using HTML5, Silverlight, Flash or normal forms and it provide some unique features such as upload progress, image resizing and chunked uploads.

You can try & test Plupload by click here.

Can't be done without co-operating binaries being installed on the client. There is no safe mechanism for an AJAX framework to read the contents of a file and therefore be able to send it to the server. The browser supports that only as a multipart form post from a file input box.

The problem is with the way the HTML file upload control works, has nothing to do with ASP.net, for the file upload control to work you need a full post of the form data. You can only simulate that your are not doing a full postback, by doing all the operation in a hidden iframe that does the actual uploading

The sites you see that do provide this functionality generally use flash or an iframe so that the postback occurs in the iframe and gives the illusion of an ajax request.

HTH

OneSHOT

I've tried swfupload (http://swfupload.org/), but do keep in mind that you have to jump through hoops if you're using forms authentication with non-IE browsers. This is apparently a flash bug, and it's not fixed in flash 10. I decided against using it in our framework because of this bug, but it was otherwise a great product.

I recommend the uploader widget from YUI. See http://developer.yahoo.com/yui/uploader/

I think you could use it to accomplish your goal. Your javascript would need to fetch the file back down to the client from the server after it completed its upload. But the page would not refresh--the upload is through flash and a hidden iframe. The download to show the file's contents to the user would be via ajax.

If the user does not "approve" the upload, then simply make another ajax call to the server to delete the file.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!