Asynchronous File Upload

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Frinavale
    Recognized Expert Expert
    • Oct 2006
    • 9749

    Asynchronous File Upload

    I'm attempting to upload a file asynchronously to the server by using an IFrame.

    I have an Asp.NET FileUpload control on the page (which renders as an <input type="file> HTML element) and a submit button along with an IFrame.

    I am attempting to redirect the form's target into the IFrame.

    I have the following JavaScript function which should redirect the form's action into an Iframe on the page:
    Code:
    function redirectFormAction(iframeTargetID) {
        var theForm = document.forms['theFormsID'];
        theForm.target = iframeTargetID;
    }
    This method is called on the button's onclick event:
    Code:
    <input id="fup" type="file" style="width: 222px;" name="fup"/>
    <input id="upload" type="submit" style="width: 222px;" onclick="ChangeHasOccurred(); AllowPostback('xyz'); redirectFormAction('ctl00_theiframe');" value="Preview" name="upload"/>
    <iframe id="ctl00_theiframe" src="#" name="ctl00_theiframe">
    </iframe>
    The page form is still submitting in the window (not the iframe)...what am I doing wrong?

    -Frinny
  • acoder
    Recognized Expert MVP
    • Nov 2006
    • 16032

    #2
    See the code for this. Should give some ideas.

    Comment

    • Frinavale
      Recognized Expert Expert
      • Oct 2006
      • 9749

      #3
      I'm actually using that article (along with a few others) as a reference right now.

      I didn't want to create an Object that is going to do something during the form's onsubmit either (because it should just happen when the button's clicked).

      And instead of dynamically creating the iframe I've just added it to the page to keep things simple...

      I didn't really see the point of creating an Object to do all of that when I could keep things much simpler..

      However, I haven't tried "f.setAttribute ('target', name);"
      [edit]
      The setAttribute() method did not make any difference.
      It still isn't working, the page is still isn't being submitted using the iframe.
      [/edit]

      Comment

      Working...