Flash MultiPowUploader - 不可见时触发上传按钮?

时间:2013-04-02 21:59:21

标签: jquery flash multifile-uploader

我正在使用ElementIT的MultiPowUpload v3.3,我有独立的Flash部分工作。我的问题是当我使上传按钮不可见并需要通过标准表单元素按钮触发上传时。

<form id="myform" name="myform" action="" method="post">
<select name="menu" MULTIPLE size="2">
<option value="1">some menu item 1</option>
<option value="2">some menu item 2</option>
</select>
<input name="text" type="text" value="some text">
<input type="hidden" name="hdn_frm_submit" id="hdn_frm_submit" value="Upload Files" />
<input type="submit" name="btn_sub" value="Submit Form">

<div id="MultiPowUpload_holder"></div>

<script type="text/javascript" src="Extra/swfobject.js"></script>
<script type="text/javascript">
var params = {  
    BGColor: "#FFFFFF"
};

var attributes = {  
    id: "MultiPowUpload",  
    name: "MultiPowUpload"
};

//MultiPowUpload partameters goes here
var flashvars = {       
  "serialNumber": "MY_SERIAL_NUMBER_INSERTED_HERE",
  "uploadUrl": "insert_the_processing_page_here",
  "formName": "myform",
      "uploadButton.visible": "false",
  "uploadButton.action": "2",
  "useExternalInterface": "true"
};
//Default MultiPowUpload should have minimum width=400 and minimum height=180
swfobject.embedSWF("ElementITMultiPowUpload.swf", "MultiPowUpload_holder", "400", "250", "10.0.0", "Extra/expressInstall.swf", flashvars, params, attributes);
</script>
</form>

我在页面上有jQuery,所以我将在doc.ready部分放置Submit按钮click handler。如何使用jQuery解决Flash上​​传器的上传按钮?任何反馈将不胜感激。

1 个答案:

答案 0 :(得分:1)

您可以使用ExternalInterface
http://www.element-it.com/OnlineHelpMulti/MultiPowUpload_Manual_HTML/tutorial.html#javaScript

可能您正在寻找uploadAll方法
http://www.element-it.com/OnlineHelpMulti/Methods.html#uploadAll

您需要添加到示例中的代码是:

<script>
   $(document).ready(function () {
     $("#btn_sub").click(function() {
       $("#MultiPowUpload").uploadAll("uploadfiles.aspx");
     });
   });
</script>

但您还需要将按钮类型从submit更改为button,以防止从html提交表单。

<input type="button" name="btn_sub" value="Upload Files">

我用过这个文档:
http://api.jquery.com/ready/
http://api.jquery.com/click/
http://api.jquery.com/id-selector/