James Lin
James Lin

Reputation: 26538

how to get fileList for jquery fileupload plugin?

I am trying to trigger the send action by code, from the documentation which looks like this:

$('#fileupload').fileupload('send', {files: filesList});

But I am having trouble finding out how to populate filesList, any ideas?

this is an extract from my html input:

<input type="text" name="name"/>    
<input type="file" name="image" id="image" />

This is my code try to sendit

form.fileupload('send', {
    url: api_urls['wishlistitem']+'?format=json',
    files: $('input[name="image"]',form).files,
});

Upvotes: 3

Views: 7999

Answers (1)

Ionică Bizău
Ionică Bizău

Reputation: 113365

From documentation:

The second argument must be an object with an array (or array-like list) of File or Blob objects as files property.

Create the input type file with multiple upload:

<input type="file" name="files[]" multiple/>

And in jQuery create the array:

var filesList = $('#fileInput')[0].files;

Upvotes: 6

Related Questions