我有一个运行良好的上传表单,但我想以编程方式更改设置,但出现错误。
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 中以获得相同的错误。我真的很感激任何帮助。
你的代码是错误的。 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>
顺便说一句,我从不考虑 uploadify 中的文件夹参数。我在服务器端脚本中定义了上传文件夹。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)