[html] 파일 태그 (input type=’file’)

less than 1 minute read

html tag중 파일 관련 개발 시 활용할 수 있는 태그로, 설정가능한 속성 중에는 accept, capture, files, multiple등이 있다.

Reference

Concept

(1) Attributes

  • accept
    허용하는 파일 타입 지정 가능

    .jpg, .pdf, .doc…

audio/, video/, image/*

  • multiple
    하나 이상의 파일을 선택 가능하게 할 수 있는 지 아닌 지 여부
    <input type="file" multiple> 
    
  • capture
    카메라 어플리케이션을 연동 사용 여부 (모바일에서 유용함)
    <input type="file" accept="image/*" capture>
    

Usecase

  • jpg의 파일 1개만을 허용하는 기능 개발

Comments