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>
$(开发者_Go百科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.
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.
Try a different function name. I had a similar problem and found out that renaming updateSettings()
to updateForm()
solved the issue in my case.
I got this error when using Uploadify inside a jquery dialog box.
The solution was to initialize Uploadify after the dialog was created.
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
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
精彩评论