2012-07-01 46 views
0

Iam用JQuery Uploadify V3.1瘋狂。Uploadify v3.1通過POST數據

// 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傳遞到服務器端,在Uploadify V2有一個方法uploadifySettings通過 「scriptData」,而不是在V3 ?有人知道這是如何工作的?

如果別人需要的線索:

'onUploadStart' : function(file) { 
      var key = $('#key').val(); 
      $("#file_upload").uploadify('settings', 'formData', {'key' : key}); 
     }, 

回答

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); 
    } 
}); 
}); 
+0

作品的形象使用,但如何做到這一動態? 「onUploadStart」不會改變任何東西? – opHASnoNAME

+0

@ArneRie即時添加另一個答案,請期待它,在我的項目中我使用該代碼,它的工作正常。 –

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>'); 
     } 
    }); 
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); 
} 

這是我的代碼,我在我的項目中,實際上即時通訊uploding圖像到一個臨時文件夾和動態即時顯示到我的DIV(上課「tempImageContainer2」)標籤onUploadSuccess