0

我正在尝试将一些帖子参数动态添加到 swfupload。但是当脚本执行并上传文件时,POST 参数会丢失。任何信息我可能做错了什么?我的代码如下:

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

}, 
4

1 回答 1

0

我通过将 file_dialog_complete_handler 的事件处理程序添加到 SWFUpload 构造中,将我的连接到文件对话框完成中:

file_dialog_complete_handler : fileDialogComplete,

然后我实现了javascript函数fileDialogComplete如下(我有2个表单字段,类别和注释并使用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. 然后在服务器端,你可以看到我的帖子变量:

Post[Filename]=Finland.png
Post[category]=2
Post[notes]=Here we go
Post[Upload]=Submit Query
于 2012-12-19T04:50:16.760 回答