jqueryinternet-explorerjqueryform

IE jQuery form trigger click manually, access is denied


I have a form to upload a image with jQuery form. everting is ok, but when I want trigger file input type click after select a file, in IE ONLY returns this error: access is denied

$('#imageform #photoimg').trigger('click'); or setTimeout(function(){$('#imageform #photoimg').trigger('click')},1000);
$('#photoimg').live('change',function()
{
    //$("#preview").html('');
    //$("#preview").html('<img src="loader.gif" alt="Uploading...."/>');
    $("#imageform").ajaxForm(
        success: function(out) {
            var imageur = out;
            // do tiny work with out;
        }
    }).submit();
});

Where is the problem and how I can resolve it?


Solution

  • By default IE does not let you trigger file element change.

    If you want you this feature, can use ajaxuploader or fileuploader:

    var uploader = new qq.FileUploader({
        // pass the dom node (ex. $(selector)[0] for jQuery users)
        element: document.getElementById('file-uploader'),
        // path to server-side upload script
        action: '/server/upload'
    });