title: jQuery Plupload restrict number of uploads
body: <p>I have been working on this code for some time now trying to get it to work properly.  I want to restrict the use from uploading more that 2 images in total. </p>
  
  <p>The line <code>var upa = $('.uploader').plupload('getUploader');</code> it giving an error of Uncaught TypeError: Object [object Object] has no method 'plupload' </p>
  
  <pre><code>    var maxfiles=2;
      $('.uploader').each(function(){
          var $uploader = $(this);
          $uploader.pluploadQueue($.extend({
              runtimes: 'html5,flash,html4',
              url : '../admin/extras/upload.php',
              max_file_size : '2mb',
              chunk_size : '2mb',
              unique_names : true,                
              filters : [
                  {title : "Image files", extensions : "jpg"}
              ],
              resize : {width : 800, height : 600, quality : 90},
              flash_swf_url : 'js/mylibs/forms/uploader/plupload.flash.swf',
              init : {
                  FilesAdded: function(up, files) {
                      plupload.each(files, function(file) {
                          if (up.files.length &gt; maxfiles) {
                              up.removeFile(file);
                          }
                          var upa = $('.uploader').plupload('getUploader');
                          var i = 0;
                          while (i&lt;=upa.files.length) {
                              ultimo = upa.files.length;
                              if (ultimo &gt; 1) {
                                  if (i &gt; 0) {
                                      ultimo2 = ultimo - 1;
                                      ii = i-1;
                                      if (ultimo2 != ii) {
                                          if (up.files[ultimo - 1].name == upa.files[i-1].name) {
                                              up.removeFile(file);
                                          }
                                      }
                                  }
                              }
                              i++;
                          }
                      });
                      if (up.files.length &gt;= maxfiles) {
                          $('#uploader_browse').hide("slow");
                      }
                  },
                  FilesRemoved: function(up, files) {
                      if (up.files.length &lt; maxfiles) {
                          $('#uploader_browse').fadeIn("slow");
                      }
                  }
              }
          }));
          $uploader.find('.plupload_button').addClass('button grey btn');
          $uploader.find('.plupload_add').addClass('icon-plus');
          $uploader.find('.plupload_start').addClass('icon-ok');
      });
  </code></pre>
  
  <p>The error is generated when i upload images. I don't know what I am missing but any help on this is greatly appreciated. </p>