0

I want to pass multiple values to a function in uploadify.

The way you call a function is like this

$("#id").uploadify("upload", fileId);

here fileId is id of only one file to be uploaded.

I have a scenario where i itertate over a table to get file ids to upload then i want to pass those ids to this function call. How can i do that.

and here is currently what i am doing, which obviously isn't working.

var imagesToUpload = [];
$.each(data.validationResult, function (index, obj) {
var imageToUpload = GetFileToUpload(obj.ImageName);
   if(imageToUpload){
      imagesToUpload[imageToUpload] = imageToUpload;
   }
});
$("#id").uploadify("upload", imagesToUpload);// this is not working

1 Answer 1

1

You can use Function.prototype.apply() to pass arguments to a function as an array.

$('#id').uploadify.apply(null, ['upload'].concat(imagesToUpload)); 

This assumes that imagesToUpload is an Array of the arguments you want to pass.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.