要的js一个都不能少,他们之间是有依赖关系的。
jquery-1.8.2.min.js
jquery.ui.core.js
jquery.ui.widget.js
jquery.fileupload.js
jquery.iframe-transport.js
jquery.fileupload-process.js
jquery.fileupload-validate.js
(最后2个js是有依赖的,缺少的话acceptFileTypes,maxFileSize 不会进行验证)
<script> $(function () { uploadImageAjaxDelete = function (url,obj){ $.ajax({url:url,async:false,dataType:"text",success:function(data){ if(data=='1'){ //如果删除成功,恢复file的使用,同时是图片渐变消失 $(obj).parent().children("input[type='file']").removeAttr("disabled"); $(obj).parent().children("img").fadeOut("slow",function(){ $(this).add($(obj).parent().children("a")).add($(obj).parent().children("input:hidden")).add($(obj).parent().children("br")).remove(); }); }else{ alert('图片删除失败!'); } }}); } $("input[type='file']").fileupload({ url: 'image_ajax_save.action', dataType: 'json', autoUpload: true, acceptFileTypes: /(\.|\/)(gif|jpe?g|png)$/i, maxFileSize: 2097152// 2 MB }).on('fileuploadadd', function (e, data) { $(this).parent().children("label").remove(); $("<p class='uploadImgLoad'>上传中... 0%</p>").appendTo($(this).parent()); $(this).attr("disabled",true); }).on('fileuploadprocessalways', function (e, data) { if(data.files.error){ $(this).parent().children("p").remove(); $(this).removeAttr("disabled"); if(data.files[0].error=='acceptFileTypes'){ $(this).parent().append("<label class='error'>图片类型错误</label>"); } if(data.files[0].error=='maxFileSize'){ $(this).parent().append("<label class='error'>图片不能大于2M</label>"); } } }).on('fileuploadprogressall', function (e, data) { var $p = $(this).parent().children("p"); var progress = parseInt(data.loaded / data.total * 100, 10); if($p.length==0){ $("<p class='uploadImgLoad'>上传中... "+progress+"%</p>").appendTo($(this).parent()); }else{ console.info(progress); $p.text('上传中... '+progress+'%'); if(progress==100){ $p.fadeOut("slow",function(){ $(this).remove(); }); } } }).on('fileuploaddone', function (e, data) { if(data.result.result=='error'){ $(this).removeAttr("disabled"); alert('抱歉,上传过快,请稍等!'); }else if(data.result.result=='success'){ $(this).parent().prepend($("<a href='#' > 删除</a>").attr("onclick","uploadImageAjaxDelete('image_ajax_delete.action?dbFileName="+data.result.dbFileName+"',this)").add("<br/>")) .prepend($("<img width='140' height='90' border='0' />").attr("src",data.result.url)) .prepend($("<input type='hidden' name="+data.result.hiddenName+" id="+data.result.hiddenName+" value='"+data.result.dbFileName+"' />")); } }); }); </script>
操作的时候一定查看:API,Demo
https://github.com/blueimp/jQuery-File-Upload/wiki/API
http://blueimp.github.io/jQuery-File-Upload/basic.html
此外 fireFox 的 debug插件配合使用,有脚本输出的断点功能,以及console.info的显示。
相关推荐
jQuery-File-Upload-9.11.2(完整版,插件已下载),官方的很多引用文件都是线上的,加载很慢,下载到本地后更靠谱,这个版本是已经整理好的,直接调用后台php的部分也在其中,可以直接应用到项目中,直接拷贝过去就...
jQuery-File-Upload上传插件
一个很详细的jquery-file-upload的java案例
jQuery-File-Upload-master
jQuery-File-Upload
一款好用的jQuery-File-Upload上传插件,便于上传文件
jQuery-File-Upload的例子
jQuery-File-Upload for asp.net MVC
支持上传多个文档Ajax 开发实例, Chrome上传多个没问题,但IE上传会出现错误 序列化类型为“System.Collections.Generic.LinkedListNode`1[[ViewDataUploadFilesResult, App_Web_5x24fddx, Version=0.0.0.0, ...
jQuery-file-upload的各种语言拖拽上传文件功能。官网最新版本
该插件支持多文件选择上传、支持客户端处理上传进度,另外还支持跨域,块和可恢复的文件上传、客户端图像大小调整等。本人独家推荐 需要的兄弟拿去用
blueimp-jQuery-File-Upload-9.10.1-0-gc9d8bc7.zip
这个插件支持多文件选择和拖拉上传。它能够上传前预览图片,并用一个进度条来提醒用户
NULL 博文链接:https://bijian1013.iteye.com/blog/2111087
jQuery-File-Upload-9.19.1 文件上传