从 IE 中的输入类型文件中获取文件数据<10

问题描述 投票:0回答:0

我正在尝试通过带有表单数据的表单上传 pdf 文件,并且正在以下浏览器下测试功能:edge 和 internet explorer。我使用 FileApi,我的方法在 edge 和 IE11 和 IE10 下有效,但在 IE 下无效<10, I read that FileApi is no longer supported under IE<10. The goal is to test where the formdata can be used under internet explorer. The usefulness is to try to print a pdf file with the formdata, and that it works under edge, IE11, IE10, IE<10 as far as possible.

HTML

<body>
  
    <form name="pocform" id="pocform" enctype="multipart/form-data">
    <div class="panel-body">
    <input id="uploadfile" name="uploadfile" type="file" value="" size="60"/><br/>
    <input type="button" class="btn btn-primary" value="Upload" id="uploadButton" name="uploadButton" onclick="onClickImpression()"/>
    </div>
  </form>
</body>

JS

<script type="text/javascript">
    function onClickImpression() {
      var fileElement = document.forms[0].uploadfile.files; //works in Edge, IE11 and IE10, not in IE<10
      var file = fileElement[0];
      var formData = new FormData();
       formData.append('uploadfile', file);
       try {
        req.open("POST", url, false);
        req.send(formData);
        }
    catch (e) {
        alert(e.toString());
    }
    }
    </script> 

在 IE 中是否有等效项<10 to this:

var fileElement = document.forms[0].uploadfile.files;

我试试这个,但在 IE 中不起作用<10

document.getElementById('uploadfile').files;

谢谢。

javascript html file internet-explorer fileapi
最新问题
© www.soinside.com 2019 - 2024. All rights reserved.