Search code examples
modal-dialoguploadify

Getting Uploadify to work in a modal dialog


I'm using the Flash version of Uploadify in a modal dialog. If I close the modal dialog when the upload is in progress, the upload is canceled. I understand that due to Flash limitations, the upload button must always be visible for the upload to succeed, so I'm looking for a workaround to allow the upload to continue.

I tried moving the upload button to the body of the HTML file when the modal is closed, but that didn't work:

function closeModal() {
  $('body').append('#fileInput'); // # fileInput contains the Uploadify button
  $uploadModalOuter.fadeOut(200);
}

Solution

  • I came up with a pretty simple workaround for this: I'm now modifying the z-index instead of hiding the modal. Seems to work great.

    function closeModal() {
        // We can't use fadeOut because it hides the Uploadify Flash button, which causes uploads to fail
        $uploadModal.css("z-index", -999);
    }
    
    function openModal() {
        $uploadModal.css("z-index", 999);
    }