开发者

jquery uploadify

开发者 https://www.devze.com 2022-12-12 21:52 出处:网络
Okay, i can\'t post all the code to this because it\'s just unnecessary. But here\'s the problem. I have a tabbed dialogue (ui.tabs) which contains an uploadify form for uploading files. However on a

Okay, i can't post all the code to this because it's just unnecessary. But here's the problem.

I have a tabbed dialogue (ui.tabs) which contains an uploadify form for uploading files. However on an earlier tab I check the status of a radiobutton to determine whether to allow only image files or flash files.

I have initialized uploadify as such beforehand, within $(document).ready:

$("#uploadify").uploadify({params});

... including 'fileDesc' and 'fileExt' parameters. In itself, it works fine. But once it has been initialized, I wish to alter the settings using:

$("#uploadify").uploadifySettings('fileDesc','blah blah');
$("#uploadify").uploadifySettings('fileExt','.ext');

... but when i do this, Firebug spouts the following:

document.getElementById(a(this).attr("id") + "Uploader").updateSettings 开发者_如何学编程is not a function http://localhost/projectname/Javascript/jquery.uploadify.v2.1.0.min.js Line 26

Now obviously there is nothing wrong with uploadify itself, but I may be a total noodle here. Is this happening because it thinks that '#uploadify' hasn't been initialized yet?


You should see accepted answer in this thread. The key is to call the $("#uploadify").uploadifySettings(); inside upload start handler, or form submit handler.

Overall, the js code should be like this:

jQuery(function($){

  //make uploadify
  $("#uploadify").uploadify({params});

  //handle form submit
  $("#form").submit(function(e){
    //prefent form submit
    e.preventDefault();

    //change the uploadify setting, ex. scriptData
    $("#uploadify").uploadifySettings("scriptData", {'file_id': '345'});

    //start upload
    $("#uploadify").uploadifyUpload();

  });
});

This code work for me, I hope it work in your case. Form submit can be replaced by another function, such as in function startUpload that exist in example script from uploadify website.


I am struggling with the same problem.

Someone over at the Uploadify forums thinks it is a bug related to the situation where the parent element had the style display:none.

http://www.uploadify.com/forum/viewtopic.php?f=7&t=2163


You presume that #uploadify hasn't been initialized yet. Did you put your uplaodify code into

$(document).ready(function() { ... });

?


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

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


IE can cache the uploadify.swf file, and for some reason, this will cause a failure for some users. In the Uploadify setup configuration, modify the "uploader" URL to include a unique value in the querystring to prevent caching:

'uploader': '/Content/uploadify.swf?nocache=' + new Date().getTime()

This fixed the issue for me.


Try

$("#uploadify").uploadifySettings({fileDesc: 'blah blah', fileExt: '.ext'});
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号