简体   繁体   English

SWFUpload不发送POST参数

[英]SWFUpload not sending POST params

I'm trying to dynamically add some post parameters to swfupload. 我正在尝试向swfupload动态添加一些发布参数。 But when the script executes and the file is uploaded, POST parameters goes missing. 但是,当脚本执行并上传文件时,POST参数将丢失。 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的事件处理程序添加到SWFUpload结构中,我将我的文件连接到文件对话框完成中:

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): 然后,我按如下方式实现了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. 现在,选择文件后,它将启动fileDialogComplete方法,该方法将启动上传。 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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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