자바스크립트를 이용해서 업로드 이미지 사이즈(넓이, 높이) 구하기
<script type="text/javascript">
window.onload=function(){
const file = document.getElementById('file');
file.onchange=function(){
if(!file.files[0]){
alert('파일을 선택하세요!');
return;
}
const reader = new FileReader();
reader.readAsDataURL(file.files[0]);
reader.onload = function(){
const image = new Image();
image.src = reader.result;
image.onload=function(){
//이미지 파일의 넓이와 높이
alert(this.width +", " + this.height);
};
};
};
};
</script>
<input type="file" id="file">
'IT설명서' 카테고리의 다른 글
[오라클] c##으로 시작하는 계정 이름 부여 (0) | 2024.06.13 |
---|---|
[jQueryUI] datepicker를 이용한 시작일, 종료일 지정 (0) | 2024.06.12 |
[특수문자] 온도를 나타내는 특수문자 표시 방법 (0) | 2024.06.11 |
[오라클] SQL Developer에서 접속 창이 안 보일 경우 (0) | 2024.06.10 |
[스프링] xml 파일에서 cvc-elt.1.a: Cannot find the declaration of element 'beans'. 오류 발생 (0) | 2024.06.10 |