简体   繁体   中英

SWFUpload not sending POST params

I'm trying to dynamically add some post parameters to swfupload. But when the script executes and the file is uploaded, POST parameters goes missing. Any info what I might be doing wrong? My code is below:

var swfu = new SWFUpload({  
upload_url : "http://something/location",
    flash_url : "http://an-absolute-url-to/swfupload.swf", 
file_post_name : "fileObject", 
http_success : [201, 202], 
assume_success_timeout : 0, 
file_types : "*.jpg;*.gif;*.png", 
file_types_description: "Web Image Files", 
file_size_limit : "1000 MB",
file_upload_limit : 10, 
file_queue_limit : 2, 
debug : true, 
prevent_swf_caching : false, 
button_placeholder_id : "button", 
button_width : 61, 
button_height : 22, 
button_text : "<b>Click</b> <span class=\"redText\">here</span>", 
button_text_style : ".redText { color: #FF0000; }", 
button_text_left_padding : 3, 
button_text_top_padding : 2, 
button_action : SWFUpload.BUTTON_ACTION.SELECT_FILES, 
button_disabled : false, 
button_cursor : SWFUpload.CURSOR.HAND, 
button_window_mode : SWFUpload.WINDOW_MODE.TRANSPARENT, 
file_queue_error_handler : function(e){window.alert("ERror@")}, 
upload_start_handler : function(e){
        $.ajax({url:"/auth",
data:"file=" + e.name,
    success: function(msg){
        $.swfu.addPostParam("param1",msg.p1);
        $.swfu.addPostParam("param2",msg.p2);
}
    });

}, 

I wired mine into the file dialog completion by adding the event handler for file_dialog_complete_handler to the the SWFUpload construction:

file_dialog_complete_handler : fileDialogComplete,

Then I implemented the javascript function fileDialogComplete as follows ( I have 2 form fields, category and notes and get at them using jquery):

function fileDialogComplete(msg) {  
        swfu.addPostParam( "category", $('#category').val());
        swfu.addPostParam( "notes", $('#notes').val());
        swfu.startUpload();     
} 

Now, when the files are selected, it kicks off the fileDialogComplete method, which kicks off the upload. Then on the server side, you can see my post variables:

Post[Filename]=Finland.png
Post[category]=2
Post[notes]=Here we go
Post[Upload]=Submit Query

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM