views:

475

answers:

1

Hello,

I am developing an application that manages a photo contest. In that application, I use an AsyncFileUpload control for the user selected photo. The server-side UploadedComplete does basic validation, and scales/clip the image as necessary.

The problem is, when i click on the submit button on the page, the content of the AsyncFileUpload gets sent with the other user-submitted data, so the user gets to wait twice as long to get a response from the server (I'm expecting photos that are between 3 and 7 Mb big, which takes a minute or two to upload).

My form looks like that:

<%-- ... snip - all other fields ... -->
<div style="margin-top: 20px; margin-bottom: 5px;">
    <span class="texteB"><b>Upload a photo</b></span><br />
    Browse your computer to find a photo.</div>
<div>
    <asp:AsyncFileUpload onclientuploaderror="UploadError" persistfile="true" onuploadedcomplete="fuPhoto_UploadedComplete"
        completebackcolor="#52ad0b" onclientuploadstarted="UploadStarted" id="fuPhoto"
        throbberid="throbber" runat="server" />
</div>
<div runat="server" id="throbber" style="display: none; margin: 8px 0 15px 0">
    <div style="float: left; width: 48px;">
        <img src="images/throbber.gif" /></div>
    <span class="texteV_14pt"><b>Please wait while
        <br />
        your photo is uploaded...</b></span>
</div>
<div style="margin-top: 20px; margin-bottom: 20px;">
    Please double-check your informations and press Send when ready.</div>
<div>
    <asp:ImageButton onclick="btnSubmit_Click" ImageUrl="images/bt_envoyer_demande.gif"
        runat="server" id="btnSubmit" />
</div>

Is there something I missed out in the documentation? I've been working on this all day without much success.

Thanks in advance!

+1  A: 

The AsyncFileUpload doesn't really work like this. It only really works when you use the filedata in the OnUploadedComplete event.

I'd just bite the bullet and use something like SWFUpload or just use a native FileUpload control.

David Neale
I ended up using a very terrible IFrame hack due to deadline glooming, but if I checked SWFUpload and it could have done the job for me. I just had all the code working already and a simple 5 line "hack" seemed correct.
David L.-Pratte