views:

3334

answers:

4
+1  Q: 

jquery uploadify

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?

A: 

Try

$("#uploadify").uploadifySettings({fileDesc: 'blah blah', fileExt: '.ext'});
ZippyV
A fair response, but that is what I tried first time around - when that didn't work I simplified it into the code mentioned above. I still get the 'updateSettings is not a function' error. :\
David
A: 

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

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

?

igorp1024
One more thing: are the swf scripts placed on the server accessible?Not sure, but seems like uploadify dynamicaly embeds them in the page...
igorp1024
I did, as mentioned above, it's sitting on localhost, i have access to the script (it works just fine on it's own, i just can't seem to change the settings with uploadifySettings. I just don't know...Yes, it is in document.ready.
David
Okay, it doesn't answer the question really, so i'm still open for a response. But in order to get it to work, i've simply re-initialized the whole thing upon click of the radio buttons, simply to get it to work. NOT an ideal solution at all. So i'm still open to ideas of actually having it correct...
David
A: 

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

Joubert Nel
that could very well be the problem ... although i'm not gonna attempt to 'fix' it while it's working, i've bookmarked the link for future reference. :)
David
+3  A: 

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.

Donny Kurnia