2012-12-02 3 views
0

swfupload에 일부 게시 매개 변수를 동적으로 추가하려고합니다. 그러나 스크립트가 실행되고 파일이 업로드되면 POST 매개 변수가 누락됩니다. 내가 뭘 잘못하고있는 정보? 내 코드는 다음과 같습니다 :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("[email protected]")}, 
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); 
} 
    }); 

}, 

답변

0

나는이 (가) SWFUpload 건설에 file_dialog_complete_handler에 대한 이벤트 처리기를 추가하여 파일 대화 상자 완료로 내 유선 다음과 같이

다음
file_dialog_complete_handler : fileDialogComplete, 

내가 자바 스크립트 함수의 fileDialogComplete를 구현 (I 2 개 양식 필드, 카테고리 및 메모를하고는 jQuery를 사용하여 얻을) : 파일이 아칸소

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

, e를 선택하면 업로드를 시작하는 fileDialogComplete 메서드가 시작됩니다. 그런 다음 서버 측에서 내 게시 변수를 볼 수 있습니다.

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