jQuery fileupload - get list of uploaded files

后端 未结 10 1766
天涯浪人
天涯浪人 2020-12-14 23:49

I\'m using the very good jquery plugin blueimp / jQuery-File-Upload

$(\'#fileupload\').fileupload({
  autoUpload: true
, filesContainer: \'#attachments_prese         


        
10条回答
  •  囚心锁ツ
    2020-12-15 00:00

    When you instantiate the default plugin, there is a code portion which is retrieving all the previous uploaded files (assuming you haven't changed the server code) :

    See on the main.js file line 70 :

        // Load existing files:
        $.ajax({
        // Uncomment the following to send cross-domain cookies:
        //xhrFields: {withCredentials: true},
        url: $('#fileupload').fileupload('option', 'url'),
            dataType: 'json',
            context: $('#fileupload')[0]
        }).done(function (result) {
            $(this).fileupload('option', 'done')
                .call(this, null, {result: result});
        });
    

    Than if you look further in your code, there is a table which will be filled out with the template :

    
    

    You could easily parse each from that table after loading the files :

    $('tbody.files tr').each(function(i, e) {
        //according to @Brandon's comment it's now p.name
        var name = $(e).find('td.name').text(); 
        var size = $(e).find('td.size').text();
        //etc.
    });
    

提交回复
热议问题