我在非IE浏览器中遇到"输入标签"的问题
<input type="file" ...
Run Code Online (Sandbox Code Playgroud)
我正在尝试编写我的上传器,只需使用javascript和asp.net.
我上传文件没问题.
我的问题发生当我想在非IE浏览器中获取我的文件时
<input type="file" ...
Run Code Online (Sandbox Code Playgroud)
我不想直接使用,input因为它的外观没有正确改变
我写了这段代码来从硬盘上获取文件:
function $tag(_str_tag) {
return document.getElementsByTagName(_str_tag);
}
function $create(_str_tag) {
return document.createElement(_str_tag);
}
function $open_file() {
_el_upload = $create("input");
_el_body = $tag("body")[0];
_el_upload.setAttribute("type", "file");
_el_upload.style.visibility = "hidden";
_el_upload.setAttribute("multiple", "multiple");
_el_upload.setAttribute("position", "absolute");
_el_body.appendChild(_el_upload);
_el_upload.click();
_el_body.removeChild(_el_upload);
return _el_upload.files;
}
Run Code Online (Sandbox Code Playgroud)
在IE中它工作得很好并且当前返回我的文件; 在Chrome和Firefox中,加载"文件输入对话框"后,它无法返回任何文件.Opera和Safari完全没了.
我可以用这个技巧解决它,但它基本上不好.
_el_upload.click();
alert();
Run Code Online (Sandbox Code Playgroud)
我认为"回调"或"等待功能"可以解决这个问题,但我无法处理它.
我正在编写一个表单来一次选择和上传多个文件.这似乎是FF和Chrome中非常直接的任务,但在IE 7中似乎是一个限制.
有任何建议的解决方法吗?
这是我公司内部网的内部应用程序,IE是默认浏览器.现在有关升级到IE 8或9的消息,是否有人知道这是否有所作为?
引擎盖下发生了什么,这使得IE在这种情况下与FF和Chrome不同?我知道这很多,但专门用于选择和上传文件.
谢谢,拉塞尔