admin管理员组文章数量:1314488
I'm building an internal web app which allows the user to upload a file via the file input element as follows:
<input class="WebFormControls" type="file" accept=".csv" id="fileBulkCsv" name="fileBulkCsv" onchange="javascript:OnFileUploadChange();" />
The Problem
My problem is that the client's SOE uses IE8 (boo hiss, yes I know). Unfortunately, this version of IE doesn't support the accept attribute of the input element in conjunction with type="file" (works fine in Chrome).
The Question
My question is: is there another way to reproduce this behaviour? My goal is to have the browser open a file dialog which is preset to filter in only CSV files.
I've tried using both file extension pattern (".csv") and MIME type ("text/csv") arguments, but it does not work and I suspect that IE8 simply does not handle the accept attribute.
Out of Scope
Please note that I'm quite fortable with the concept of using JavaScript to validate the file name and its extension. However, this happens after the fact, once the user has already selected a file to upload. I'm looking for a way (if possible) to replicate the accept behaviour on Microsoft's browser.
Thanks!
I'm building an internal web app which allows the user to upload a file via the file input element as follows:
<input class="WebFormControls" type="file" accept=".csv" id="fileBulkCsv" name="fileBulkCsv" onchange="javascript:OnFileUploadChange();" />
The Problem
My problem is that the client's SOE uses IE8 (boo hiss, yes I know). Unfortunately, this version of IE doesn't support the accept attribute of the input element in conjunction with type="file" (works fine in Chrome).
The Question
My question is: is there another way to reproduce this behaviour? My goal is to have the browser open a file dialog which is preset to filter in only CSV files.
I've tried using both file extension pattern (".csv") and MIME type ("text/csv") arguments, but it does not work and I suspect that IE8 simply does not handle the accept attribute.
Out of Scope
Please note that I'm quite fortable with the concept of using JavaScript to validate the file name and its extension. However, this happens after the fact, once the user has already selected a file to upload. I'm looking for a way (if possible) to replicate the accept behaviour on Microsoft's browser.
Thanks!
Share Improve this question edited Jun 12, 2013 at 4:15 Mark Micallef asked Jun 12, 2013 at 4:08 Mark MicallefMark Micallef 2,7977 gold badges29 silver badges36 bronze badges1 Answer
Reset to default 9The only way you can achieve this is to use external uploader in flash or in java (applet)
You could use for example swfupload: https://code.google./p/swfupload/
Unfortunately checking file type is in html5 api, which is not support by IE8
本文标签: javascriptAccept attribute in file input for IE8Stack Overflow
版权声明:本文标题:javascript - Accept attribute in file input for IE8 - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741968482a2407690.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论