IE11下获取<input type="file">的文件名
2015-11-11 12:30
591 查看
参考:https://msdn.microsoft.com/zh-cn/subscriptions/hh772931(v=vs.85)
<!DOCTYPE html> <html > <head> <title>Files property test</title> <script type="text/javascript"> function getFiles() { // Get input element myFileList = document.getElementById("myfiles"); // loop through files property, using length to get number of files chosen for (var i = 0; i < myFileList.files.length; i++) { // display them in the div document.getElementById("display").innerHTML += "<br/>" + myFileList.files[i].name ; } } </script> </head> <body> <label>Use <strong>shift</strong> or <strong>ctrl</strong> click to pick a few files: <input type="file" multiple id="myfiles" onchange="getFiles();" /></label> <div id="display"></div> </body> </html>可以获取文件名,但是不能获取路径。IE11、FF可用[/code]
获取路径需要修改IE安全性设置,步骤是: 工具 -> Internet选项 -> 安全 -> 自定义级别 -> 找到“其他”中的“将本地文件上载至服务器时包含本地目录路径”,选中“启用”即可。
相关文章推荐
- VC++使用内联汇编的例子:冒泡法排序(从大到小排序)
- Linux 下添加硬盘/新建分区
- MyEclipse通过TomCat创建一个简单的Web后台供Android使用
- java重载和重载的区别
- 我做淘宝7年的故事
- 欢迎使用CSDN-markdown编辑器
- 使用 xheditor + prettify 做代码高亮的总结
- 如何为我们的Snappy Ubuntu应用编译并打包Snap(1)
- activemq在一台服务器上启动多个Broker
- WordPress侧边栏,小工具开发与使用
- 可变参数列表原理及应用
- 定义继承RelativeLayout的组合控件
- linux系统扫描
- 搭建lnmp环境
- Java初始入门(二)
- VC++使用内联汇编的例子:冒泡法排序(从小到大)
- Android网络层与数据层设计
- 黑马程序员——C语言基础06—数组
- fork()函数使用的链接很好
- SQL基本语句学习