views:

21

answers:

0

I'm trying to get swfUpload to work in my application for file uploads. It works, but I want to show the file upload only if the user clicks on a button (for design reasons, and because I need to have other values available on the page before this upload is created).

But in order to wait to show this upload, I have to hide the form with the input (type=file) by jquery .hide function. And then use .show when the user clicks the button. Although this works, it shows up in a rather "jerky" fashion. I assume this is because of some conflict with the fact that this form is hidden somehow by the swfupload script and all that in the first place, since that is the point of the script, to let flash create the upload button instead.

Here's my jquery code:

$("#uploadLink").click(function (event) {
    event.preventDefault();
    $('#uploadForm').show();

    $("#photo").makeAsyncUploader({
        upload_url: "/Upload/AsyncUpload/",
        flash_url: '/Scripts/swfupload.swf',
        button_image_url: '/Scripts/blankButton.png',
        disableDuringUpload: 'INPUT[type="submit"]'
    });
});

I'm using Steven Sanderson's AsyncUpload script for swfUpload (http://blog.stevensanderson.com/2008/11/24/jquery-ajax-uploader-plugin-with-progress-bar/)

Could I do this in a better way, and not have the jerky show of the upload button?