兼容ie8的多文件上传
来源:互联网 发布:在线支付网站源码 编辑:程序博客网 时间:2024/06/06 04:04
在HTML5中,表单元素有一个新的属性multiple,可实现多选功能。
<input type="file" multiple>这样就可以实现多文件上传,但是此方法不兼容ie8等低版本浏览器。所以项目中我使用的是百度的WebUpload插件,此插件在ie中底层使用flash实现多文件上传。
以下代码是简单的demo,具体使用方法可依据官方文档。
<!DOCTYPE html><html><head lang="en"> <meta charset="UTF-8"> <title></title> <link rel="stylesheet" href="webuploader.css"/></head><body><div id="uploader" class="wu-example"> <!--用来存放文件信息--> <div id="thelist" class="uploader-list"></div> <div class="btns"> <div id="picker">选择文件</div> <button id="ctlBtn" class="btn btn-default">开始上传</button> </div></div><script src="jquery-1.8.3.min.js"></script><script src="webuploader.js"></script><script> var uploader = WebUploader.create({ // swf文件路径 swf: 'Uploader.swf', // 文件接收服务端。 server: 'http://webuploader.duapp.com/server/fileupload.php', // 选择文件的按钮。可选。 // 内部根据当前运行是创建,可能是input元素,也可能是flash. pick: '#picker', // 不压缩image, 默认如果是jpeg,文件上传前会压缩一把再上传! resize: false, //去重 duplicate: true, //限制文件大小 fileSingleSizeLimit: 50000,//单位(字节B) //可上传文件的类型 accept: { extensions: 'docx,doc,xls,xlsx,ppt,pptx,wps,et,txt,ole,pdf,ceb,jpg,jpeg,bmp,png,rar,zip,caj' } }); // 当有文件被添加进队列的时候 uploader.on( 'fileQueued', function( file ) { $("#thelist").append( '<div id="' + file.id + '" class="item">' + '<h4 class="info">' + file.name + '</h4>' + '<p class="state">等待上传...</p>' + '</div>' ); }); // 文件上传过程中创建进度条实时显示。 uploader.on( 'uploadProgress', function( file, percentage ) { var $li = $( '#'+file.id ), $percent = $li.find('.progress .progress-bar'); // 避免重复创建 if ( !$percent.length ) { $percent = $('<div class="progress progress-striped active">' + '<div class="progress-bar" role="progressbar" style="width: 0%">' + '</div>' + '</div>').appendTo( $li ).find('.progress-bar'); } $li.find('p.state').text('上传中'); $percent.css( 'width', percentage * 100 + '%' ); }); uploader.on( 'uploadSuccess', function( file ) { $( '#'+file.id ).find('p.state').text('已上传'); }); uploader.on( 'uploadError', function( file ) { $( '#'+file.id ).find('p.state').text('上传出错'); }); uploader.on( 'uploadComplete', function( file ) { $( '#'+file.id ).find('.progress').fadeOut(); }); $("#ctlBtn").bind('click', function() { //向服务器端传递的参数 uploader.options.formData = {"uuid": "234124"}; uploader.upload(); });</script></body></html>
阅读全文
0 0
- 兼容ie8的多文件上传
- 兼容ie8的ajax文件上传
- 修改input file文件上传的默认样式 兼容ie8
- 兼容IE8使用ajax上传文件
- 上传图片预览,兼容IE8
- 基于ueditor的兼容IE8的多图片上传+预览效果(JSP)
- 头像上传前本地预览功能的实现(兼容ie8)
- javascript 检测上传文件是否超过2M,兼容ie、ff、chrome,不兼容ie8
- 浏览器兼容的文件上传
- IE8 下的文件上传问题
- 兼容ie8的透明度
- FileUpload 上传下载文件兼容IE8
- 图片上传预览,兼容IE6,IE8
- IE8 文件上传文件为空的问题
- 考虑浏览器兼容的文件上传
- 网站兼容IE8的方法
- IE8兼容IE7的方法
- ie8兼容ie7的样式
- Mvp实战心得(二)---Base基类的封装
- C++ Primer Notes
- decode-ways Java code
- 刷题#R9
- Android编译系统参考手册
- 兼容ie8的多文件上传
- [arc082f]Sandglass
- UnicodeDecodeError: 'gbk' codec can't decode byte 0xa4 in position 18: illegal multibyte sequence
- 函数回调机制、异步函数回调机制图例详解
- UINavigationController隐藏导航条
- 使用Jenkins+Git+Gradle自动化构建Android APK包
- 微信小程序学习笔记
- VMWare 安装
- centos7安装tomcat