JavaScript Nervgh Angular File Upload - cancelItem method not working nervgh angular-file-upload examples,nervgh/angular-file-upload,https://

This is my html code :

<input type="file" nv-file-select="" options="{ photoType: 'studentPic' }" uploader="uploader" />

This is angular code :

var uploader = $scope.uploader = new FileUploader({
            url: 'badges/photos',
            autoUpload: true
        });

        // FILTERS

        uploader.filters.push({
            name: 'customFilter',
            fn: function (item /*{File|FileLikeObject}*/ , options) {                
                return this.queue.length < 10;
            }
        });

        // CALLBACKS

        uploader.onWhenAddingFileFailed = function (item /*{File|FileLikeObject}*/ , filter, options) {
            console.info('onWhenAddingFileFailed', item, filter, options);
        };
        uploader.onAfterAddingFile = function (fileItem) {
            console.info('onAfterAddingFile', fileItem);
        };
        uploader.onAfterAddingAll = function (addedFileItems) {
            console.info('onAfterAddingAll', addedFileItems);
        };
        uploader.onBeforeUploadItem = function (item) {
            console.log("item before uploading:",item._file.type);
            console.log("item before uploading:",item._file.size);
            if((item._file.type!="image/png" && item._file.type!="image/jpeg") || item._file.size>102400){
                console.log("in if of before");
                this.cancelItem(item);
            }            
            console.log(item.photoType);
            var filename = generateUUID();
            if (item.photoType === 'studentPic') {
                $scope.pic = filename;
            }
            if (item.photoType === 'pickupPerson1Pic') {
                $scope.pickupPerson1Pic = filename;
            }
            if (item.photoType === 'pickupPerson2Pic') {
                $scope.pickupPerson2Pic= filename;
            }
            item.formData.push({
                filename: filename
            });
            console.info('onBeforeUploadItem', item);
        };
        uploader.onProgressItem = function (fileItem, progress) {
            console.info('onProgressItem', fileItem, progress);
        };
        uploader.onProgressAll = function (progress) {
            console.info('onProgressAll', progress);
        };
        uploader.onSuccessItem = function (fileItem, response, status, headers) {
            if (fileItem.photoType === 'studentPic') {
                angular.element('#picPreview').attr("src", response.url);
            }
            if (fileItem.photoType === 'pickupPerson1Pic') {
                angular.element('#pickupPerson1PicPreview').attr("src", response.url);
            }
            if (fileItem.photoType === 'pickupPerson2Pic') {
                angular.element('#pickupPerson2PicPreview').attr("src", response.url);
            }
            console.info('onSuccessItem', fileItem, response, status, headers);
        };
        uploader.onErrorItem = function (fileItem, response, status, headers) {
            console.info('onErrorItem', fileItem, response, status, headers);
        };
        uploader.onCancelItem = function (fileItem, response, status, headers) {
            console.info('onCancelItem', fileItem, response, status, headers);
        };
        uploader.onCompleteItem = function (fileItem, response, status, headers) {
            console.info('onCompleteItem', fileItem, response, status, headers);
        };
        uploader.onCompleteAll = function () {
            console.info('onCompleteAll');
        };

My uploader.onBeforeUploadItem has the condition if((item._file.type!="image/png" && item._file.type!="image/jpeg") || item._file.size>102400) and if it succeeds the I call the this.cancelItem(item) method.

 uploader.onBeforeUploadItem = function (item) {
                console.log("item before uploading:",item._file.type);
                console.log("item before uploading:",item._file.size);
                if((item._file.type!="image/png" && item._file.type!="image/jpeg") || item._file.size>102400){
                    console.log("in if of before");
                    this.cancelItem(item);
                }            
                console.log(item.photoType);
                var filename = generateUUID();
                if (item.photoType === 'studentPic') {
                    $scope.pic = filename;
                }
                if (item.photoType === 'pickupPerson1Pic') {
                    $scope.pickupPerson1Pic = filename;
                }
                if (item.photoType === 'pickupPerson2Pic') {
                    $scope.pickupPerson2Pic= filename;
                }
                item.formData.push({
                    filename: filename
                });
                console.info('onBeforeUploadItem', item);
            };

Now am I calling the cancel Item method wrongly? Because despite the conditions matching the upload of the item still continues successfully. Please help

Answer:1

I'm looking at switching from resource to restangular in my AngularJS app. I like the new model, but I have one problem. I can't figure out how to make this API call: http://localhost:8000/api/entity/...

I'm looking at switching from resource to restangular in my AngularJS app. I like the new model, but I have one problem. I can't figure out how to make this API call: http://localhost:8000/api/entity/...

  1. restangular multiple base url
  2. restangular multiple requests
  3. multiple restangular
  4. restangular post multiple parameters

I'm creating an 'advanced' Tic Tac Toe game in which each turn disappears after 10 seconds (ie: each X or O placed reverts to a blank square after 10 seconds). This all works fine, but the issue ...

I'm creating an 'advanced' Tic Tac Toe game in which each turn disappears after 10 seconds (ie: each X or O placed reverts to a blank square after 10 seconds). This all works fine, but the issue ...

Ok, i spent all day to trying "connect" css styles with svg files created in inkscape. I've got svg file with map and couple of path, and i want to change fill color when i mouseover on that path. ...

Ok, i spent all day to trying "connect" css styles with svg files created in inkscape. I've got svg file with map and couple of path, and i want to change fill color when i mouseover on that path. ...

  1. change path fill color css
  2. change path fill css
  3. change fill path
  4. change svg path fill color
  5. wpf change path fill color
  6. change svg path fill css
  7. javascript change path fill color
  8. jquery change path fill

I am using an awesome html2canvas function but I have a noob question. How do I change the field it is capturing from document.body to a specific panel? In short i need to change document.body to the ...

I am using an awesome html2canvas function but I have a noob question. How do I change the field it is capturing from document.body to a specific panel? In short i need to change document.body to the ...