Uploadify updateSettings问题 [英] Uploadify updateSettings problems

查看:90
本文介绍了Uploadify updateSettings问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的uploadify表单运行得很漂亮,但是我想以编程方式更改设置,但出现错误.

I've got an uploadify form working beautifully, but I'd like to change the settings programatically and I'm getting an error.

Uploadify在document.ready上启动,我试图将updateSettings绑定到单击按钮(也在document.ready中完成).我也尝试过在document.ready之外使用updateSettings函数-实际上在按钮上或只是在内联脚本上都得到相同的错误.

Uploadify is initiated on document.ready and I'm trying to bind the updateSettings to a button click (also done in the document.ready). I have also tried using the updateSettings function outside of the document.ready - actually on the button or just inline script to get the same error.

错误是

Error: document.getElementById(a(this).attr("id") + "Uploader").updateSettings is not a function

我的代码当前看起来像

<script>
$(document).ready(function(){

  $('#uploadify').uploadify({
    'uploader'  : 'uploadify.swf',
    'script'    : 'uploadify.php',
    'cancelImg' : 'cancel.png',
    'auto'      : true,
    'folder'    : '/uploads'
  });

  $("#changeIt").click(function(){
    $("#uploadify").uploadifySettings("folder","something_else");
  });

});
</script>

<input type="file" name="uploadify" id="uploadify" />

<a id="changeIt" src="#">Change the upload dir</a>

就像我说的那样,我尝试过在文档外部添加uploadifySettings.准备好了,我也尝试在标签本身的onclick中添加它,以得到相同的错误.非常感谢您的帮助.

Like I say, I've tried adding the uploadifySettings outside the document.ready, I've also tried adding it right in an onclick in the a tag itself to get the same error. I'd really appreciate any help.

推荐答案

您的代码错误. Uploadify不能绑定到<input type="file">,只能绑定到<div/>.请参见uploadify网站中的文档和示例.

You code is wrong. Uploadify cannot binded to a <input type="file">, only to a <div/>. See the documentation and the example in the uploadify site.

要进行渐进式增强,我需要同时包含元素<input type="file"/>和空的<div/>.然后在JavaScript代码中,删除输入元素,然后初始化uploadify.

To have progressive enhancement, I have both element, <input type="file"/> and an empty <div/>. Then in javascript code, I remove the input element and then initialize uploadify.

<input type="file" name="uploadify" />
<div id="uploadify"></div>

<script type="text/javascript">
    jQuery(function($){
      $("input[name='uploadify']").hide().remove();
      $("#uploadify").uploadify({UPLOADIFY_PARAM});
      //a click handler to change uploadify param
      //...
    });
    </script>

顺便说一句,我从没考虑过uploadify中的folder参数.我在服务器端脚本中定义了上载文件夹.

Btw, I never consider the folder parameter from uploadify. I define the upload folder in the server side scripting.

这篇关于Uploadify updateSettings问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆