1

I am uploading jpg image using the fileupload control. The image is uploaded after the page is posted back.

My problem is I want to upload the image immediately after the user double clicks on the file name or presses the open button on the select file dialogue.

I have searched a lot over the internet but I've been unable to find the suitable example for my application.

How can I achieve this?

Please help.

Thanks in advance.

Amicable
  • 3,115
  • 3
  • 49
  • 77
Malik
  • 21
  • 1
  • 1
  • 4

4 Answers4

3

Take a look at AsyncFileUpload via Ajax

http://www.asp.net/ajaxLibrary/AjaxControlToolkitSampleSite/AsyncFileUpload/AsyncFileUpload.aspx

<ajaxToolkit:AsyncFileUpload OnClientUploadError="uploadError"
    OnClientUploadComplete="uploadComplete" runat="server"
    ID="AsyncFileUpload1" Width="400px" UploaderStyle="Modern"
    UploadingBackColor="#CCFFFF" ThrobberID="myThrobber"
/> 
J.Starkl
  • 2,183
  • 1
  • 13
  • 15
2

you can do with Ajax and Jquery. Jquery File Upload

html

<input id="fileupload" type="file" name="files[]" data-url="server/yourMethodToPost/">

Jquery

$(function () {
    $('#fileupload').fileupload({
        dataType: 'json',
        done: function (e, data) {
            $.each(data.result.files, function (index, file) {
                $('<p/>').text(file.name).appendTo(document.body);
            });
        }
    });
});
Ravi Gadag
  • 15,735
  • 5
  • 57
  • 83
2

You might try to use ajax AsyncFileUpload

SztupY
  • 10,291
  • 8
  • 64
  • 87
1

If you want to upload a file to the Server you always need to do a Postback. However, there are different ways to do a postback. You can use Ajax to do a postback or partial postback.

Take a look at this topic

Community
  • 1
  • 1
Jordy van Eijk
  • 2,718
  • 2
  • 19
  • 37