IE jQuery form trigger click manually, access is denied
-
08-06-2021 - |
Question
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'
});
OTHER TIPS
I commented these lines in j query.form.js then every thing works fine for me. Don't ask me the reason even i don't have the solution for that but it works for sure.
if (io.contentWindow.document.execCommand) {
try { // #214
io.contentWindow.document.execCommand('Stop');
} catch(ignore) {}
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow