I'm new to programming, I tried to find the height and width of uploaded image so that I can set a condition based on image height and width.If it is valid I can set image path in state of my React Component.Thank you....
`
onSelectFile = e => {
if (e.target.files && e.target.files.length > 0) {
const reader = new FileReader();
var image=new Image()
reader.addEventListener('load', () =>
image.addEventListener('load', () =>{
if(this.height>600||this.width>600){
this.setState({ src: reader.result }, () => {
this.toggleTab("2")
}
else if(){
alert("Image is too small")
}
}),
);
reader.readAsDataURL(e.target.files[0]);
}
};
<input type="file" id="fileInput" name="fileInput" onChange= .
{this.onSelectFile}/>
}
`