六狼论坛

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博账号登陆

只需一步,快速开始

搜索
查看: 265|回复: 0

ajaxFileUpload实现带参数提交

[复制链接]

升级  14%

19

主题

19

主题

19

主题

秀才

Rank: 2

积分
71
 楼主| 发表于 2013-1-29 08:53:03 | 显示全部楼层 |阅读模式
修改了3个地方

createUploadForm: function(id, fileElementId, data)      {          //create form             var formId = 'jUploadForm' + id;          var fileId = 'jUploadFile' + id;          var form = $('<form  action="" method="POST" name="' + formId + '" id="' + formId + '" enctype="multipart/form-data"></form>');           var oldElement = $('#' + fileElementId);          var newElement = $(oldElement).clone();          $(oldElement).attr('id', fileId);          $(oldElement).before(newElement);          $(oldElement).appendTo(form);                    //增加文本参数的支持          if (data) {              for (var i in data) {                  $('<input type="hidden" name="' + i + '" value="' + data + '" />').appendTo(form);              }          }                    //set attributes          $(form).css('position', 'absolute');          $(form).css('top', '-1200px');          $(form).css('left', '-1200px');          $(form).appendTo('body');                 return form;      },        ajaxFileUpload: function(s) {          // TODO introduce global settings, allowing the client to modify them for all requests, not only timeout                  s = jQuery.extend({}, jQuery.ajaxSettings, s);          var id = new Date().getTime()                  var form = jQuery.createUploadForm(id, s.fileElementId, s.data);          var io = jQuery.createUploadIframe(id, s.secureuri);
您需要登录后才可以回帖 登录 | 立即注册 新浪微博账号登陆

本版积分规则

快速回复 返回顶部 返回列表