-2
jQuery('form').submit(function(e) {
        var dosya = jQuery('#uploader').plupload();
        if (dosya.files.length > 0) {
            alert("gg");
          dosya.bind('UploadProgress', function() {
                if (dosya.total.uploaded == dosya.files.length)
                    jQuery('form').submit();

            });
            dosya.start();
        } else if (dosya.files.length <= 0) {
            alert('alert alert alert');
        }
        e.preventDefault();
    });

I'm getting this error during the post process Uncaught TypeError: Cannot read property 'length' of undefined ** Can someone help me**

Roy Shmuli
  • 4,979
  • 1
  • 24
  • 38
RedFox
  • 1

2 Answers2

0

dosya.files is undefined (Null), this mean you don't have value to this variable, that why you don't have the property 'length' and you get the exception

Roy Shmuli
  • 4,979
  • 1
  • 24
  • 38
  • Yes, empty, but actually not empty so why comes empty I'm using plupload within a form comes packed with form elements, but #uploader always comes empty – RedFox Aug 02 '15 at 09:56
0

I soloved this problem it's working

  jQuery('form').submit(function (e) {
        var uploader = jQuery('#uploader').plupload('getUploader');
        if (uploader.total.uploaded == 0) {
            if (uploader.files.length > 0) {
                uploader.bind('UploadProgress', function () {
                    jQuery('#uploader').on('complete', function () {
                        jQuery('form').submit();
                    });
                });
                jQuery('#uploader').plupload('start');
            } else { jQuery('form').submit(); }
            //alert('alert alert alert');

            e.preventDefault();
        }
    });
RedFox
  • 1