Plupload - Refresh the page

Asked

Viewed 230 times

2

I’m working on an online platform for the company I work for.

On this platform I use Plupload to upload images.

Everything’s working fine, except for one part.

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

I’ve researched this and I know I can use the UploadComplete and I’ve even tried it but nothing happens after 100%.

Right now I have the simplified code just to check in:

$(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'
        }
     });
});

That’s how it works, but I don’t think it’s done the right way.

In my research I found things like init() and Uploader.bind and var = uploader = $('#uploader').pluploadQueue(); but if I use these code examples I can’t even make Plupload appear.

I accept suggestions and bug fixes.

1 answer

1

You need to bind to "Fileuploaded":

$(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
    }
  });
});
  • I already tested with Fileupload and Uploadcomplete events and could not. I inserted an Alert inside the event to know when it works. What can cause events not to trigger? Is it the plupload container? Is it because you don’t have DOCTYPE as Html5? Will be by having other plugins on the same page?

  • I’ve figured this out. If you use plupload at the beginning and then pluploadThat the event does not fire. But if you use pluploadTry in both parts the event already triggers. The problem here is that when using pluploadTry the plugin layout changes completely.. How do I fix it?

Browser other questions tagged

You are not signed in. Login or sign up in order to post.