컴포넌트로 돌아가기
드래그 앤 드롭을 지원하는 파일 업로드 컴포넌트입니다. 파일 타입 필터링, 용량 제한, 업로드 진행률 표시 등을 지원합니다.
라이브 데모
기본 사용법
파일을 선택하거나 여기에 드래그하세요
이미지 전용 (최대 5MB)
이미지를 여기에 드롭하세요 (최대 5MB)
지원 형식: image/* • 최대 크기: 5 MB
다중 파일 (개수 제한)
최대 3개 파일을 드롭하세요 (각 최대 10MB)
• 최대 크기: 10 MB • 최대 3개
크기 옵션
size="sm"
Small
size="md" (default)
Medium
size="lg"
Large
비활성화 상태
업로드가 비활성화되었습니다
Props
| 이름 | 타입 | 기본값 | 설명 |
|---|---|---|---|
files | UploadedFile[] | [] | 업로드된 파일 목록 |
onChange | (files: File[]) => void | - | Callback when files are selected |
onRemove | (file: UploadedFile) => void | - | Callback when file is removed |
multiple | boolean | false | 다중 파일 선택 허용 |
accept | string | - | 허용 파일 타입 (예: "image/*", ".pdf") |
maxSize | number | - | Maximum file size in bytes |
maxFiles | number | - | Maximum number of files |
disabled | boolean | false | 비활성화 상태 |
dragDrop | boolean | true | Enable drag and drop functionality |
placeholder | string | "파일을 선택하거나 여기에 드래그하세요" | 플레이스홀더 텍스트 |
size | "sm" | "md" | "lg" | "md" | 업로드 영역 크기 |
dot | string | - | |
style | React.CSSProperties | - |
UploadedFile 인터페이스
| Property | Type | Required | 설명 |
|---|---|---|---|
| id | string | * | docs:components.upload.props.id |
| file | File | * | docs:components.upload.props.file |
| name | string | * | docs:components.upload.props.name |
| size | number | * | docs:components.upload.props.size |
| type | string | * | docs:components.upload.props.type |
| progress | number | - | docs:components.upload.props.progress |
| status | "pending" | "uploading" | "success" | "error" | - | docs:components.upload.props.status |
| url | string | - | docs:components.upload.props.url |
| error | string | - | docs:components.upload.props.error |
파일 타입 필터 예시
image/*모든 이미지 파일image/png, image/jpegPNG, JPEG 이미지만.pdfPDF 문서만video/*모든 비디오 파일.doc, .docx, .pdf문서 파일 (Word, PDF)코드 예시
사용 팁
- • onChange로 File 객체를 받아 서버나 스토리지 서비스에 업로드하세요
- • UploadedFile의 status와 progress 필드를 활용해 업로드 진행 상태를 표시하세요
- • 검증은 클라이언트에서 수행되지만, 서버에서도 파일 크기와 타입을 항상 검증하세요
접근성
- •키보드 지원: Enter 또는 Space로 파일 선택기 열기
- •스크린 리더: 파일 입력에 적절한 aria-label 제공
- •포커스 표시: 인터랙티브 요소에 명확한 포커스 표시