Uploadify updateSettings problems

纵饮孤独 提交于 2019-12-31 05:30:13

问题


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

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.

The error is

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

And my code currently looks like

<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>

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.


回答1:


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.

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>

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




回答2:


Try a different function name. I had a similar problem and found out that renaming updateSettings() to updateForm() solved the issue in my case.




回答3:


I got this error when using Uploadify inside a jquery dialog box.

The solution was to initialize Uploadify after the dialog was created.




回答4:


I've encountered the same problem. It seems that there's a bug with auto:true, as I have another uploadify on the same page, with auto:false, and uploadifySettings works perfectly.

I've made a workaround:

  • set auto to false
  • onSelect, submit the upload, like this:

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

hth




回答5:


I received this error in Chrome when the uploadify control was inside a jquery dialog.

I ended up not using uploadify and switched to jQuery Upload File Plugin http://hayageek.com/docs/jquery-upload-file.php



来源:https://stackoverflow.com/questions/2037605/uploadify-updatesettings-problems

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!