1

Hi am a newbie to angular JS . I have been trying do something, I have a login form in which I have a file input type where user can upload his picture. The input field is like this

<input type="file" file-model="userPic"/>

So, in the controller.js file on submit of the form when I

console.log(userPic)

I get the file name, size, modified date . But I want to find the dimensions of the upload picture width and height before the form submit. I have also bower components installed I that I have jquery folder inside that I have dimensions.js file is that useful ?

I have also tried to console.log using .width().For that I changed the code a little bit

<input type="file" file-model="userPic" id="userId"/>

and in the controller.js file on form submit

console.log($('#userId').width());

I have tried this but the output I get is not correct . How would I proceed .

1

1 Answer 1

2

You'll want to use naturalWidth and naturalHeight:

$scope.userPic.naturalHeight();
$scope.userPic.naturalWidth();
Sign up to request clarification or add additional context in comments.

6 Comments

Can't I get using the file-model value I mean console.log(userPic.naturalWidth()); Instead of using the id.
you probably need to use $scope.userPic for it to work.
@William TypeError: $scope.userPic.naturalWidth() is not a function I am getting this error
@user3270582 in javascript naturalWidth is a property, JQuery manages it as a function, I fear Angularjs does not. So try to use as a property removing the () parentheses at the end.
@MarioZ If I remove the () parentheses at the end as you suggested in its undefined.
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.