1、如何让ajaxfileupload.js支持IE9、IE10?
打开ajaxfileupload 文件,找到下面的代码。
- if(window.ActiveXObject) {
- var io = document.createElement('<iframe id="' + frameId + '" name="' + frameId + '" />');
- if(typeof uri== 'boolean'){
- io.src = 'javascript:false';
- }
- else if(typeof uri== 'string'){
- io.src = uri;
- }
- }
- if(window.ActiveXObject) {
- if(jQuery.browser.version=="9.0" || jQuery.browser.version=="10.0"){
- var io = document.createElement('iframe');
- io.id = frameId;
- io.name = frameId;
- }else if(jQuery.browser.version=="6.0" || jQuery.browser.version=="7.0" || jQuery.browser.version=="8.0"){
- var io = document.createElement('<iframe id="' + frameId + '" name="' + frameId + '" />');
- if(typeof uri== 'boolean'){
- io.src = 'javascript:false';
- }
- else if(typeof uri== 'string'){
- io.src = uri;
- }
- }
- }
2、如何让ajaxfileupload.js可以在文件上传的同时传递多个台数。
找到以下代码:
- 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); //变化前
- 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.tag_name, s.tag_link, s.tag_sort, s.tag_status, s.tag_id);//变化后
接着找到:
- createUploadForm: function(id, fileElementId, tag_name, tag_link, tag_sort, tag_status, tag_id)//增加tag_name, tag_link, tag_sort, tag_status, tag_id
- {
- //create form
- var formId = 'jUploadForm' + id;
- var fileId = 'jUploadFile' + id;
- //--增加以下内容
- var tagNameId = 'tag_name' + id;
- var tagLinkId = 'tag_link' + id;
- var tagSortId = 'tag_sort' + id;
- var tagStatusId = 'tag_status' + id;
- var tagIdId = 'tag_id' + id;
- //--end
- var form = $('<form action="" method="POST" name="' + formId + '" id="' + formId + '" enctype="multipart/form-data"></form>');
- var oldElement = $('#' + fileElementId);
- var newElement = $(oldElement).clone();
- //--增加以下内容
- var tagNameElement = '<input type="text" name="tag_name" value="'+tag_name+'">';
- var tagLinkElement = '<input type="text" name="tag_link" value="'+tag_link+'">';
- var tagSortElement = '<input type="text" name="tag_sort" value="'+tag_sort+'">';
- var tagStatusElement = '<input type="text" name="tag_status" value="'+tag_status+'">';
- var tagIdElement = '<input type="text" name="tag_id" value="'+tag_id+'">';
- //--end
- $(oldElement).attr('id', fileId);
- $(oldElement).before(newElement);
- $(oldElement).appendTo(form);
- //--增加以下的内容
- $(tagNameElement).appendTo(form);
- $(tagLinkElement).appendTo(form);
- $(tagSortElement).appendTo(form);
- $(tagStatusElement).appendTo(form);
- $(tagIdElement).appendTo(form);
- //--end
- //set attributes
- $(form).css('position', 'absolute');
- $(form).css('top', '-1200px');
- $(form).css('left', '-1200px');
- $(form).appendTo('body');
- return form;
- },
修改完后,如何使用?
- $.ajaxFileUpload({
- url:web_url,
- secureuri:false,
- //以下为增加的传递参数
- tag_name:tag_name,
- tag_link:tag_link,
- tag_sort:tag_sort,
- tag_status:tag_status,
- tag_id:tag_id,
- //--end
- fileElementId:result[0],
- dataType: 'json',
- success: function (data,status){}
- //以下省略
OK,done.