-1

When inserting image in angular i want check image width and height.If width and height does not match i give an error

$scope.imageChanged = function(files,selected_creative_size)
{
    $scope.backup_creative_size = '';   
    if (files != null) {
        var file = files[0];            
        //Here i want to check image size and height
        if()
        {                       
            //Add data into database
        }
        else
        {
            $scope.backup_creative_size = 'Please select' + file_prop[0]+' * '+file_prop[1];
        }
    }
};
vivek
  • 383
  • 2
  • 23

1 Answers1

1

Try using this method on the event onChange this will have maximum size as 3 mb

$scope.uplFile = angular.element("input[type='file']")[0].files[0];
            if ($scope.uplFile.size < 3145728) {
              if ( $scope.uplFile.type == "image/jpg" || $scope.uplFile.type == "image/jpeg") {
               //your code
              } else {
                //your code
              }
            } else {
              //your code
            }