我对JQuery Uploadify V3.1感到疯狂。
// setup fileuploader
$("#file_upload").uploadify({
'swf': 'flash/uploadify.swf',
'uploader' : 'upload/do-upload',
'debug' : false,
'buttonText': 'Files auswählen',
'multi': true,
'method': 'POST',
'auto': false,
'width': 250,
'queueSizeLimit' : 10,
'fileSizeLimit' : '100MB',
'cancelImg': 'img/uploadify-cancel.png',
'removeCompleted' : true,
'onUploadSuccess' : function(file, data, response) {
$('#message').append(data);
},
'onUploadError' : function() {
$('#message').html('<h2>Fehler beim Upload</h2>');
}
});
开始下载onClick
// handle the event stuff
$("#event_start_upload").on({
click: function(){
var key = $('#key').val();
if (key.length < KeyLength) {
$('#form-encryption-control').addClass('error');
return;
} else {
$('#form-encryption-control').removeClass('error');
}
// some space for new download links
$('#message').empty();
$('#file_upload').uploadify('upload','*')
}
});
我的问题是:我必须将addtional params传递给serverSide,在Uploadify V2中有一个方法uploadifySettings传递“scriptData”,但不是在V3中?有人知道这是如何工作的吗?
如果其他人需要线索:
'onUploadStart' : function(file) {
var key = $('#key').val();
$("#file_upload").uploadify('settings', 'formData', {'key' : key});
},
答案 0 :(得分:4)
要通过uploadify发送数据,您可以使用formData
例如:
$(function() {
$("#file_upload").uploadify({
'formData' : {'someKey' : 'someValue', 'someOtherKey' : 1},
'swf' : '/uploadify/uploadify.swf',
'uploader' : '/uploadify/uploadify.php',
'onUploadStart' : function(file) {
$("#file_upload").uploadify("settings", "someOtherKey", 2);
}
});
});
答案 1 :(得分:2)
$("#image_upload1").uploadify(uploadifyBasicSettingsObj);
uploadifyBasicSettingsObj.onUploadSuccess = function(file, data, response)
{
$('.tempImageContainer2').find('.uploadify-overlay').show();
/* Here you actually show your uploaded image.In my case im showing in Div */
$('.tempImageContainer2').attr('style','background- image:url("../resources/temp/thumbnail/'+data+'")');
$('#hidden_img_value2').attr('value',data);
}
这是我在我的项目中使用的代码,其中我实际上将图像上传到临时文件夹并动态显示该图像到我的DIV
(具有类'tempImageContainer2')标记onUploadSuccess
答案 2 :(得分:1)
答案 3 :(得分:1)
只需在代码中添加'formData'
,如下所示:
$("#file_upload").uploadify({
'swf': 'flash/uploadify.swf',
'uploader' : 'upload/do-upload',
'debug' : false,
'buttonText': 'Files auswählen',
'multi': true,
'method': 'POST',
'auto': false,
'width': 250,
'queueSizeLimit' : 10,
'fileSizeLimit' : '100MB',
'cancelImg': 'img/uploadify-cancel.png',
'removeCompleted' : true,
'formData' : {'K':'V','K':'V','K':'V'},
'onUploadSuccess' : function(file, data, response) {
$('#message').append(data);
},
'onUploadError' : function() {
$('#message').html('<h2>Fehler beim Upload</h2>');
}
});