views:

7128

answers:

7

I have a update panel, in the update panel I have fileupload control and button control, On button click, I need the file that I have upload in the fileupload control in updatepanel.

Exact scenario, I have 8 tabs on page, each tab contains too much information, One of the tab is Attachment, when user click on Add New Attachment Modal Popup shown, Modal contains detailsview in Updatepanel and in the detailsview I have fileupload control, when user hit save button, detailsview inserting event fired, In the inserting event I need the file that I have upload.
Please Note, My page is heavy and I don't want full postBack.


Does anyone have solution of this issue?

Advance thanks for your kind help.....

+4  A: 

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.

AnthonyWJones
thanks for quick replyIs there any trick or work around to acheive this?
Muhammad Akhtar
There is no trick or work around, thats the point of safety it wouldn't be safe is there was a work round. Consider the sorts of things a malicious coder could do if such a work round existed then you realise why this sort of thing is blocked.
AnthonyWJones
+24  A: 

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 componet for this question. This is an open source plug-in of jQuery. It is Plupload that allows you to upload files using HTML5 Gears, Silverlight, Flash, BrowserPlus or normal forms, providing some unique features such as upload progress, image resizing and chunked uploads.

You can try & test Plupload by click here.

Soul_Master
Great answer. I'd upvote...but I ran out for today!! Someone give this guy a +1.
jrista
What he is doing put fileupload control on another page and on the attachment form, took IFRAME and set source fileuploaded control page. On the AsyncPostBack fileupload control page is post back and upload the attached file.... But I have different Scenario here Like I have mention in my question, I have detailsview and in the detailsview I have fileUpload control and other information as well, When user hit save button I need binary information of image on the same page rather on other, By the way that's is not solution in my scenario.... Thanks for reply
Muhammad Akhtar
this type of solution I have implmented himself early, but will not help in my scenario.
Muhammad Akhtar
For your request, You must modify your current detail for detail please see my updated answer.
Soul_Master
Exact scenario, I have 8 tabs on page, each tab contains too much information, One of the tab is Attachment, when user click on Add New Attachment Modal Popup shown, Modal contains detailsview in Updatepanel and in the detailsview I have fileupload control, when user hit **save** button, **detailsview inserting event** fired, In the inserting event I need the file that I have upload. Please Note, My page is heavy and I don't want full postBack.
Muhammad Akhtar
On the modal popup, there is DetailsView in which fileupload control and other controls exist, user hit SAVE button, I need to store File(Any type of File) binary information and other details in the DB.
Muhammad Akhtar
I Realy Appreciate your quick Responses. Thanks alot
Muhammad Akhtar
Can you apply my answer to solve your problem? What's your problem? Please let me know.
Soul_Master
Exact scenario: I have 8 tabs on page, each tab contains too much information, One of the tab is Attachment, when user click on Add New Attachment Modal Popup shown, Modal Popup contains detailsview in Updatepanel and in the detailsview I have fileupload control and other control, when user hit **save** button, **detailsview inserting event** fired, In the inserting event of DetailsView I need the binary information of Attachment, Please note that I need File/Attachment details on the same page. Thanks
Muhammad Akhtar
Can you provide your email, I will email you the images, you will clearly understand my problem, Thanks for YOUR kind HELP
Muhammad Akhtar
Soul_Master--------------live.com
Soul_Master
I think you have some problem with DetailView? you can't modify DetailView by adding ajax upload control or some problem or other problem.
Soul_Master
A: 

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

OneSHOT
if you use IFrame, file uploaded information will only available in the IFrame page source
Muhammad Akhtar
but I don't have scenario like this, I have tried this solution.
Muhammad Akhtar
A: 

Not sure I agree with @OneSHOT - take a look at how kijiji does image uploads, for one example.

chris
+1  A: 

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

Jaime
Possibly you need to give more info to get more up votes, but how you describe is essentially how sites like GMail do their Ajax uploading.
Craig
A: 

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.

ScottE
A: 

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.

Larry K