ajaxFileupload 多文件上传

修改前的代码:

    var oldElement = jQuery('#' + fileElementId);
var newElement = jQuery(oldElement).clone();
jQuery(oldElement).attr('id', fileId);
jQuery(oldElement).before(newElement);
jQuery(oldElement).appendTo(form);

要实现多个文件上传,就改成下面的样子:

    if(typeof(fileElementId) == 'string'){
fileElementId = [fileElementId];
}
for(var i in fileElementId){
var oldElement = jQuery('#' + fileElementId[i]);
var newElement = jQuery(oldElement).clone();
jQuery(oldElement).attr('id', fileId);
jQuery(oldElement).before(newElement);
jQuery(oldElement).appendTo(form);
}

初始化的代码:

    $.ajaxFileUpload({
url:'/ajax.php',
fileElementId:['id1','id2']//原先是fileElementId:’id’ 只能上传一个
});

实例调用:

       var numArr = [];
var txt = $("#fileList").find("input:file"); //获取所有上传附件框
for (var i = 0; i < txt.length; i++) {
numArr.push(txt.eq(i).attr('id')); //将附件框的ID添加到数组中
} //提交表单
$.ajaxFileUpload
(
{
url: '/Selector/Upload', //用于文件上传的服务器端请求地址
type: 'post',
data: { ProjectId: 'lunis' }, //此参数非常严谨,写错一个引号都不行
secureuri: false, //一般设置为false
fileElementId: numArr,
dataType: 'json', //返回值类型 一般设置为json
success: function (data, status) //服务器成功响应处理函数
{ },
error: function (data, status, e)//服务器响应失败处理函数
{
alert(e);
}
}
)

ajaxFileupload 多文件上传的更多相关文章

  1. ajaxFileupload多文件上传

    最近有个功能模块需要上传图片,为了和之前的伙伴们保持一致我也使用了ajaxFileupload, 但是源码只支持单文件上传,所以百般斟酌之下决定修改源码,废话不多说直接上代码 HTML上传代码段: & ...

  2. ajaxfileupload.js 文件上传

    一,前台代码. <input id="fileToUpload" type="file" size="25" name="f ...

  3. ajaxfileupload多文件上传 - 修复只支持单个文件上传的bug

    搜索: jquery ajaxFileUpload AjaxFileUpload同时上传多个文件 原生的AjaxFileUpload插件是不支持多文件上传的,通过修改AjaxFileUpload少量代 ...

  4. ajaxFileUpload+struts2实现多文件上传

    以前有介绍过ajaxFileUpload实现文件上传,但那是单文件的,这次介绍多文件上传. 单文件上传参考:http://blog.csdn.net/itmyhome1990/article/deta ...

  5. springmvc环境下使用ajaxfileupload.js进行文件上传

    controller: /* #region */ @RequestMapping(produces = "text/html;charset=UTF-8", value = &q ...

  6. 十九、多文件上传(ajaxFileupload实现多文件上传功能)

    来源于https://www.jb51.net/article/128647.htm 打开google 搜索"ajaxFileupload' ‘多文件上传"可以搜到许许多多类似的, ...

  7. uedit修改文件上传路劲,支持api文件接口

    首先修改一个东西ueditor/ueditor.config.js serverUrl: URL + "php/controller.php" 原来 serverUrl: &quo ...

  8. Spring MVC 文件上传 & 文件下载

    索引: 开源Spring解决方案--lm.solution 参看代码 GitHub: pom.xml WebConfig.java index.jsp upload.jsp FileUploadCon ...

  9. Jersey实现文件上传下载

    一 文件上传 使用ajaxFileUpload进行文件上传的前端处理.在ajaxFileupload.js中,针对服务端返回的类型增加text判断, //ajax文件上传 function ajaxF ...

随机推荐

  1. HTTP、TCP、IP、协议

    HTTP(HyperText Transfer Protocol) 即超文本传输协议,现在基本上所有web项目都遵从HTTP协议(协议就是一种人为的规范). 目前绝大部分使用的都是HTTP/1.1版本 ...

  2. 2019-03-29-day022-封装与类方法与静态方法

    昨日回顾 抽象类 规范代码,规定子类必须实现某个方法的名字 不能实例化 from abc import ABCMeta, abstractmethod class 抽象类名(metaclass=ABC ...

  3. LeetCode—66、88、118、119、121 Array(Easy)

    66. Plus One Given a non-negative integer represented as a non-empty array of digits, plus one to th ...

  4. 获取图像的ROI模板区域

    前言 项目需要得到视频帧图像的某一区域作为模板,首先需要确定ROI区域的坐标范围,很简单,直接上代码. % /********************************************* ...

  5. jquery实现拖拽进度条并显示百分比的特效

    #box{position: relative; width: 200px; height: 50px; border: 1px solid #eee; margin: 50px auto 0;} # ...

  6. js获取当前时间戳的三个方法

    var time1 = Date.parse(new Date()); var time2 = new Date().valueOf(); var time3 = new Date().getTime ...

  7. java路径

    System.out.println(ResourceUtils.getURL("classpath:").getPath());

  8. LeetCode - Minimum Area Rectangle

    Given a set of points in the xy-plane, determine the minimum area of a rectangle formed from these p ...

  9. 【liunx】sftp常用命令

    sftp是Secure FileTransferProtocol的缩写,安全文件传送协议.可以为传输文件提供一种安全的加密方法.sftp与 ftp有着几乎一样的语法和功能.SFTP为 SSH的一部分, ...

  10. C语言函数指针的使用

    使用函数指针时一定要注意,因为c不会检查参数是否正确 区分返回指针的函数和函数指针 int *f4();返回一个整数指针 int (*f5)();返回整数的函数指针 int * (*f6)();返回整 ...