182
rated 0 times
[
187]
[
5]
/ answers: 1 / hits: 17279
/ 6 Years ago, thu, february 8, 2018, 12:00:00
I'm implementing a check in which I dont want to upload the image which has size greater than 4MB
. I'm using file reader
and new image()
. I've the image size and width. But how can I get the filesize.
function previewImage(element) {
var reader = new FileReader();
reader.onload = function (event) {
seAddArtist.imageSource = event.target.result;
$scope.$apply();
};
// when the file is read it triggers the onload event above.
reader.readAsDataURL(element.files[0]);
}
var img = new Image();
img.onload = function () {
alert(this.width + 'x' + this.height);
}
I am implementing these two combine but how can i check the size of image?
More From » angularjs