I use the blueimp file uploader to upload files to my webspace. How can I get all files in the list with their status?

I have a separate button which is outside the #fileupload divs and want to get an array or something like that with all files, which were uploaded.

Have I to iterate over the html code and parse the filename and status? I cannot believe that, but I also cannot find a function which returns me this information.

有帮助吗?

解决方案 2

As I mentioned in my question I solved it with iterating over all elements in the list, looking for teh delete button and extracting the filename from the url of the delete button.

var files = new Array();
$("#fileupload td.delete button[data-type='DELETE']").each(function() {
    //get the basename of the url: http://abc/def/file.txt --> file.txt
    var name = $(this).attr("data-url").replace(/\\/g,'/').replace( /.*\//, '');
    files.push(name);
});

Does someone else has a better solution?

其他提示

A callback for successful upload is provided:

var arrNames = new Array();

//File uploader
$('#fileupload').fileupload().bind('fileuploaddone', 
    function (e, data) {
       //Add names
       arrNames[arrNames.length + 1] = data.result.files[0].name;
    }
);

arrNames holds the names of the uploaded files

(...) downloadTemplateId: null, downloadTemplate: function (o) { } (...)

You could set downloadTemplate function and do here everything that you need with downloaded files. o.files contains response from server.

in file:script.js

add code :

getFiles__Name(data.files[0].name);

under line :

add: function (e, data) {

and in your page add :

var files=new Array();
function getFiles__Name(name){
    files.push(name);
}

where files will contains all file's name. in my opinion this is not also the best solution.

I was able to get an array of files that had already been uploaded by taking FabriGad Ahmed's answer and tweaking it.

In my view I added the following script:

var img_files=[];
function getFiles__Name(name){
img_files.push(name);
}

In jquery.fileupload-ui.js i added the following to the done function:

//get the names of the already uploaded files
if (files){
$.each(files, function( index ) {
getFiles__Name( files[index].name );
});
}

This gives me an array of successfully uploaded files. Again, if there is a better way of doing this, I'd love to know.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top