【问题标题】:SWFUpload not sending POST paramsSWFUpload 不发送 POST 参数
【发布时间】:2012-11-19 20:18:36
【问题描述】:

我正在尝试将一些帖子参数动态添加到 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);
}
    });

}, 

【问题讨论】:

    标签: jquery ajax flash upload swfupload


    【解决方案1】:

    我通过将 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();     
    } 
    

    现在,当文件被选中时,它会启动 fileDialogComplete 方法,该方法会启动上传。然后在服务器端,可以看到我的post变量:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-03-07
      • 1970-01-01
      • 2014-08-01
      • 2016-05-15
      • 2018-05-30
      • 2017-02-02
      相关资源
      最近更新 更多