Plupload - refresh the page

2

It's this: I'm working on an online platform for the company I work for.

On this platform I use Plupload to upload images.

It's all working fine except for one part.

After the images are uploaded (100%), I want the page to be updated, as the images go to a <div> apart.

I've already researched this and I know I can use UploadComplete and I've tested it, but nothing happens after 100%.

At this point I have the simplified code just to see how it is:

$(function() {
    $("#uploader").plupload({
        runtimes : 'html5,html4',
        url : 'upload.php',
        resize : {
          width : 800,
          height : 500,
          quality : 90,
          crop: false
        },
        filters : {
          max_file_size : '10mb',
          mime_types: [{
             title : "Image files",
             extensions : "jpg,jpeg,gif,png"
          }]
        },
        rename: true,
        sortable: true,
        dragdrop: true,
        views: {
          list: false,
          thumbs: true,
          active: 'thumbs'
        }
     });
});

So it works, but I do not think it's done right.

In the search I did I found things like init() and Uploader.bind and var = uploader = $('#uploader').pluploadQueue(); but if you use these code examples and Plupload does not appear.

I accept suggestions and bug fixes.

    
asked by anonymous 31.01.2014 / 02:37

1 answer

1

You need to bind to the "FileUploaded" event:

$(function() {

$("#uploader").plupload({
    runtimes: 'html5,html4',
    url: 'upload.php',
    resize: {
        width: 800,
        height: 500,
        quality: 90,
        crop: false
    },
    filters: {
        max_file_size: '10mb',
        mime_types: [{
            title: "Image files",
            extensions: "jpg,jpeg,gif,png"
        }]
    },
    rename: true,
    sortable: true,
    dragdrop: true,
    views: {
        list: false,
        thumbs: true,
        active: 'thumbs'
    }
});

var uploader = $('#uploader').pluploadQueue();

uploader.bind('FileUploaded', function() {
    if (uploader.files.length == (uploader.total.uploaded + uploader.total.failed)) {
                    location.reload(); // REFRESH AO BROWSER
    }
  });
});
    
31.01.2014 / 03:16