0

我的上传表单运行良好,但我想以编程方式更改设置,但出现错误。

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

错误是

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>

就像我说的,我尝试在 document.ready 之外添加 uploadifySettings,我还尝试在 a 标签本身的 onclick 中添加它以获得相同的错误。我真的很感激任何帮助。

4

5 回答 5

2

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

为了进行渐进式增强,我同时拥有元素<input type="file"/>和空的<div/>. 然后在javascript代码中,我删除输入元素,然后初始化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>

顺便说一句,我从不考虑上传的文件夹参数。我在服务器端脚本中定义上传文件夹。

于 2010-01-13T10:45:05.310 回答
1

尝试不同的函数名称。我有一个类似的问题,发现重命名updateSettings()解决updateForm()了我的问题。

于 2012-10-05T23:48:23.493 回答
0

在 jquery 对话框中使用 Uploadify 时出现此错误。

解决方案是在创建对话框后初始化 Uploadify。

于 2011-03-31T01:57:12.453 回答
0

我遇到了同样的问题。似乎有一个错误auto:true,因为我uploadify在同一页面上有另一个错误auto:false,并且uploadifySettings工作正常。

我做了一个解决方法:

  • 将自动设置为假
  • onSelect,提交上传,像这样:

    ... 'onSelect' : function(event, data){ $('#someID').uploadifySettings('param', 'value'); $('#someID').uploadifyUpload(); } ...

hth

于 2010-10-01T15:34:24.967 回答
0

当 uploadify 控件位于 jquery 对话框中时,我在 Chrome 中收到此错误。

我最终没有使用uploadify并切换到jQuery Upload File Plugin http://hayageek.com/docs/jquery-upload-file.php

于 2016-08-04T15:20:56.853 回答