How to I preload existing files and display them in the blueimp upload table?

Doug Wolfgram picture Doug Wolfgram · Feb 22, 2013 · Viewed 15.8k times · Source

I am using the jquery-ui version of Blueimp upload and I like how I can format a table and display files that were just uploaded. But I'd like to use it as a file manager as well so I want to preload existing files and display than as if they were just uploaded. How can I do that? A sample link to where someone else has addressed this would suffice. BTW, I am uploading several different file types, not just images.

Thanks!

Answer

MagyaDEV picture MagyaDEV · Feb 12, 2014

Or without an ajax call:

  1. Prepare array containing details of existing files, e.g:

    var files = [
        {
            "name":"fileName.jpg",
            "size":775702,
            "type":"image/jpeg",
            "url":"http://mydomain.com/files/fileName.jpg",
            "deleteUrl":"http://mydomain.com/files/fileName.jpg",
            "deleteType":"DELETE"
        },
        {
            "name":"file2.jpg",
            "size":68222,
            "type":"image/jpeg",
            "url":"http://mydomain.com/files/file2.jpg",
            "deleteUrl":"http://mydomain.com/files/file2.jpg",
            "deleteType":"DELETE"
        }
    ];
    
  2. Call done callback

    var $form = $('#fileupload');        
    
    // Init fileuploader if not initialized
    // $form.fileupload();
    
    $form.fileupload('option', 'done').call($form, $.Event('done'), {result: {files: files}});