본문으로 건너뛰기
cccskills
무료GitHub에 공개

file-input

Use when you need to upload and handle files.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

설치 방법 보기

포함된 파일(2)

  • SKILL.md5.5 KB
  • references/pattern.md25.0 KB

SKILL.md(원문)

설치하기 전에 에이전트에게 전달되는 지시 내용을 확인할 수 있습니다.

File Input

Upload and handle files

What it solves

A File Input is a form component that allows users to select one or more files from their device's file system and upload them to a server. It ranges from the native <input type="file"> control to enhanced drop zones with drag-and-drop, file previews, upload progress indicators, and validation feedback. File inputs appear in document management, profile photo upload, e-commerce product imagery, form attachment flows, and media-rich applications.

When to use

  • Profile and avatar upload – Users select a photo for their account.
  • Document submission – Forms that require attached PDFs, contracts, or ID documents.
  • Media uploads – Images or videos for social media, e-commerce listings, or galleries.
  • Bulk import – CSV or JSON files for data import workflows.
  • Email attachments – Web mail applications.

When to avoid

  • Camera capture on mobile – Use <input type="file" capture="environment"> or capture="user" to open the camera directly.
  • Cloud file selection – Google Drive or Dropbox pickers require their own SDKs.
  • Very large files – Consider chunked upload APIs rather than a standard form file input.
  • Real-time streaming content – Not appropriate for live audio/video streams.

Implementation workflow

  1. Confirm the pattern matches the problem and constraints before copying the example.
  2. Start from the anatomy and examples in references/pattern.md, then choose the smallest viable variation.
  3. Apply accessibility, performance, and interaction guardrails before layering visual polish.
  4. Use the testing guidance to verify behavior across keyboard, screen reader, responsive, and failure scenarios.

Accessibility guardrails

Keyboard Interaction Pattern

KeyAction
TabMoves focus to the file input or drop zone
Enter / SpaceOpens the native file browser dialog
Tab (in file list)Moves focus to the next file item's remove button
Enter / SpaceActivates the focused remove button
DeleteRemoves focused file from the selection list (where implemented)
EscapeCancels an in-progress drag-and-drop operation

Performance guardrails

  • File selection dialog open: < 100ms from click to dialog appearance
  • File preview generation: < 200ms for image thumbnails (up to 5 MB)
  • Client-side validation: < 50ms per file
  • Progress bar update: < 16ms per frame (smooth animation)
  • Memory usage: < 50KB per file input component; image preview memory managed with URL.revokeObjectURL()

Common mistakes

Client-Side Validation Only

The Problem: Validating file type by extension only on the client allows users (or malicious actors) to rename files and bypass restrictions.

How to Fix It? Validate both client-side (for UX) and server-side (for security).

// Client-side check (UX only)
function isValidFileType(file, accept) {
  return accept.split(',').some(type => {
    type = type.trim();
    if (type.startsWith('.')) return file.name.endsWith(type);
    if (type.endsWith('/*')) return file.type.startsWith(type.slice(0, -1));
    return file.type === type;
  });
}
# Server-side check (security-critical) — Python example

allowed_types = ['image/jpeg', 'image/png', 'application/pdf']
mime_type = magic.from_buffer(file_bytes, mime=True)
if mime_type not in allowed_types:
    raise ValueError("Invalid file type")

No Upload Feedback for Large Files

The Problem: Users submit a form, see nothing happen for 30 seconds, and assume it is broken. They click submit again, causing duplicate uploads.

How to Fix It? Always show upload progress for uploads that will take more than 1 second.

const xhr = new XMLHttpRequest();
xhr.upload.addEventListener('progress', (e) => {
  if (e.lengthComputable) {
    const percent = Math.round((e.loaded / e.total) * 100);
    progressBar.setAttribute('aria-valuenow', percent);
    progressBar.style.width = `${percent}%`;
    progressText.textContent = `${percent}%`;
  }
});

Not Handling Drop Zone Keyboard Access

The Problem: A drop zone implemented as a <div> is not keyboard-accessible, excluding users who cannot use a mouse.

How to Fix It? Make the drop zone keyboard operable.

<!-- Good: keyboard-accessible drop zone -->
<div
  class="file-input__dropzone"
  role="button"
  tabindex="0"
  aria-label="Upload files. Press Enter or Space to open file browser."
>
  <!-- ... -->
</div>
dropzone.addEventListener('keydown', (e) => {
  if (e.key === 'Enter' || e.key === ' ') {
    e.preventDefault();
    fileInput.click();
  }
});

Related patterns


For full implementation detail, examples, and testing notes, see references/pattern.md.

Pattern page: https://uxpatterns.dev/patterns/forms/file-input

리뷰

아직 리뷰가 없습니다. 사용해 본 소감을 남겨 주세요.

댓글

로그인 없이 쓸 수 있습니다. 사용 후기, 질문, 작동하지 않은 환경 등을 편하게 남겨 주세요.

아직 댓글이 없습니다. 첫 댓글을 남겨 보세요.

보내면 바로 공개됩니다. 이메일 주소나 전화번호 같은 개인 정보는 쓰지 마세요. URL은 2개까지입니다.

0 / 1,000자

이 양식은 reCAPTCHA로 보호되며 Google 개인정보처리방침 및 서비스 약관이 적용됩니다.

같은 저장소의 스킬

accordion

무료

Use when implementing expand and collapse content sections.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

thedaviddias/ux-patterns-for-developers2662026년 10월 5일 업데이트

Use when implementing user account configuration and preferences.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

thedaviddias/ux-patterns-for-developers2662026년 10월 5일 업데이트

Use when implementing social activity and updates stream.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

thedaviddias/ux-patterns-for-developers2662026년 10월 5일 업데이트

ai-chat

무료

Use when implementing conversational AI chat interfaces.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

thedaviddias/ux-patterns-for-developers2662026년 10월 5일 업데이트

Use when implementing handling AI-specific errors.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

thedaviddias/ux-patterns-for-developers2662026년 10월 5일 업데이트

Use when implementing loading states for AI operations.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

thedaviddias/ux-patterns-for-developers2662026년 10월 5일 업데이트

thedaviddias의 스킬 모두 보기

이 스킬의 문제 신고