JavaScript
javaScript - input type="file" 특정 파일확장자 이미지 업로드
새발개발JA
2021. 5. 1. 22:26
반응형
이미지 업로드 기능을 구현 중이다. 특정 파일확장자만 업로드 하고 싶다면
<input>에 accept 속성을 추가하자 !
<input type="file" accept=".gif, .jpg, .png"> // gif, jpg, png 파일만 보여줌
<input type="file" accept="audio/*"> // 모든 오디오 파일을 보여줌
<input type="file" accept="video/*"> // 모든 비디오 파일을 보여줌
<input type="file" accept="image/*"> // 모든 이미지 파일을 보여줌
파일업로드 버튼을 눌러

파일선택창이 나타나면 !! accept 로허락한 파일만 마우스 클릭이 가능하다.

반응형