IE不允许上传文件,如果它不是keybord点击输入类型=文件 [英] IE doesn't allow to upload the file, if it is not keybord click for input type=file
问题描述
我有一个要求,我需要从另一个按钮触发输入[type = file]并上传文件。该输入[type = file]是用于浏览用户想要上传的文件的弹出窗口。这个窗口打开成功,但上传文件时,它给了我 SCRIPT5:访问被拒绝错误
。我不能用输入[type = file]替换假按钮,有没有一种方法可以触发点击输入[type = file],即使它不是通过键盘单击并仍然上传文件。根据我的研究,IE不允许上传文件,除非我们通过键盘点击触发input-type = file。
var uploadConfig = {
init:function(){
$('input#fileUpld_input') .livequery(click,function(){
});
},
open:function(){
$('input#fileUpld_input')。trigger('click');
},
上传:function(){
$('。start')。click();
浏览器
< input type =fileid =fileUpld_inputname =fileUpld_inputclass =fileUpld>
使用其他答案中显示的代码: working JSFiddle
< input type =fileid =fileUpld_inputname =fileUpld_inputclass =fileUpld>
我有同样的问题,但确定它是用IE而不是代码。在花费太多时间试图解决我代码中的错误之后,我启动了笔记本电脑,无法复制它。最终重启并重新启动IE解决了这个问题。
I have a requirement where i need to trigger the input[type=file] from another button and upload the files. This input[type=file] is a popup window for browsing the file which the user wants to upload. This window opens successfully but when uploading the file, it gives me SCRIPT5: Access is Denied error
. I cannot replace the fake button with input[type=file], is there a way i can trigger click on input[type=file] even it is not from keyboard click and still upload the file. As per my research IE doesn't allow upload file unless we trigger input-type=file via keyboard click.
var uploadConfig ={
init: function(){
$('input#fileUpld_input').livequery("click",function() {
});
},
open: function() {
$('input#fileUpld_input').trigger('click');
},
upload: function(){
$('.start').click();
}
Browser
<input type="file" id="fileUpld_input" name="fileUpld_input" class="fileUpld">
Use the code shown in the other answer worked for me: working JSFiddle
<input type="file" id="fileUpld_input" name="fileUpld_input" class="fileUpld">
I had the same problem, but determined that it was with IE not the code. After spending waaay too much time trying to sort out the error in my code; I fired up my laptop and could not replicate it. Eventually a reboot and restart of IE fixed the issue.
这篇关于IE不允许上传文件,如果它不是keybord点击输入类型=文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!