October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsSlow PC?RecommendedPC slow today? Run a repair scan before it gets worseResolve common Windows issues and optimize system performance.Scan NowOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
World desk4 min

React File Input Component: Build an Accessible Picker and Upload Form

Use the browser’s native file input in React, read selections from its files property, and submit named fields with FormData. Learn how to handle labels, multiple files, accept hints, and server-side validation.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

For most React apps, a file picker is simply the browser’s native <input type="file">. Give it a visible label and a name, read selected files from its files property, and use FormData to submit them when needed. Keep the input itself browser-managed: do not try to control its selection with a React value prop.

Build a reusable React file picker

This component supports one or multiple files, an optional picker type hint, and a callback for the selected File objects. Its state is only a snapshot for displaying the selection; it does not control the browser’s file picker.

import { useId, useState } from 'react';

export function FilePicker({ multiple = false, accept, onFilesSelected }) {
  const inputId = useId();
  const [files, setFiles] = useState([]);

  function handleChange(event) {
    const selected = Array.from(event.currentTarget.files ?? []);
    setFiles(selected);
    onFilesSelected?.(selected);
  }

  return (
    <div>
      <label htmlFor={inputId}>Choose file{multiple ? 's' : ''}</label>
      <input
        id={inputId}
        name="files"
        type="file"
        accept={accept}
        multiple={multiple}
        onChange={handleChange}
      />
      {files.length > 0 && (
        <ul aria-live="polite">
          {files.map((file) => (
            <li key={`${file.name}-${file.lastModified}`} >
              {file.name} ({file.size} bytes)
            </li>
          ))}
        </ul>
      )}
    </div>
  );
}

useId supplies an ID that can safely associate each component instance’s label with its input. React explains the labeling and input behavior in its input reference; MDN documents the selected files and file-picker attributes in its file input reference.

Read and submit selected files

A file input exposes a FileList through HTMLInputElement.files. Convert it to an array if the UI needs to map, count, preview, or validate selected files. Each File includes values such as name, size, type, and lastModified.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
#1 Best Overall
acer SD Card Reader USB C, Dual Slots USB Type C to Micro SD Card Adapter
  • 【Ultra-Fast Data Transfer】Experience blazing-fast 5Gbps data transfer with this USB 3.0 SD Card Reader, ensuring quick and efficient file transfers for photos, videos, and other media. Backward-compatible with USB 2.0 for added flexibility. Easily review and transfer data from security cameras, wildlife monitors, or car cameras, gopro without hassle(📌Note:only reads and transfers data from the SD and TF card, not directly connect to the camera)
  • 【Simultaneous Dual-Card】Save time and boost productivity with dual card slots that allow simultaneous reading and writing on both microSD and SD cards. USB-A and USB-C dual header design makes the micro SD Card Reader perfect for photographers, video editors who need quick and efficient file management(📌Note:Thick cases may prevent full insertion)
  • 【Compact & Travel-Friendly】Designed for convenience, the slim and lightweight card reader for camera memory card fits perfectly in your camera bag or laptop sleeve. Protective covers at both ends shield the ports from dust and liquid, while the attached cord keeps everything secure and easily accessible. A reliable companion for on-the-go professionals and creatives(📌Note: "SD"card and "Micro SD" card not included.)
  • 【Plug-and-Play】The SD Card Reader for PC does not require driver or software installation, just connect to your device and start transferring files instantly. Compatible with Windows 11/10/8/7, macOS, and most Android devices. Crafted from heat-resistant aluminum materials, this SD Card Reader for PC delivers reliable performance and enhanced durability, even during long working(📌Note: SD Slot does not support CF express Type A/B/C Cards; SIM, XQD, MS Cards and Memory Stick)
  • 【Wide Device Compatibility】The USB C SD Card Reader works seamlessly with PCs, computers, laptops, cameras, smartphones and tablets featuring USB-C or USB-A ports, including MacBook Air/Pro, XPS, iPhone 15/16, iPad Pro, Samsung Galaxy S23, Microsoft Surface, Acer Aspire, and Predator series. Perfect for quickly accessing files directly on your device without additional apps or internet connections(📌Note:Not compatible with “Lightning” port devices)

Use a named field with FormData

For a conventional form, give the input a name and create FormData from the submitted form. The browser includes named form values, including selected files.

function UploadForm() {
  function handleSubmit(event) {
    event.preventDefault();
    const formData = new FormData(event.currentTarget);
    fetch('/upload', { method: 'POST', body: formData });
  }

  return (
    <form onSubmit={handleSubmit}>
      <label htmlFor="attachments">Attachments</label>
      <input id="attachments" name="attachments" type="file" multiple />
      <button type="submit">Upload</button>
    </form>
  );
}

When using fetch with FormData, do not manually set a multipart Content-Type header; let the browser provide the multipart boundary. Confirm that the field name and the server’s expected request format match. MDN’s FormData append reference documents appending File values and using the same key for multiple values.

Rank #2
USB C SD Card Reader, Type C SD Card Reader, Supports SD and MicroSD Memory Card Adapters for iPhone 15 16/iPad/MacBook/Mac, Trail Camera Viewer Plug and Play -2 Slots
  • 【2-in-1 SD Card Reader】This sd card reader adopts dual card slot design, compatible with SD/SDHC/SDXC/MicroSD/MicroSDXC/MicroSDHC memory cards. You can easily save the photos inside the SD card to your iPhone/iPad/Mac/Camera, view the photos and videos in the memory card anytime and anywhere, and upload them to social platforms, it is a good partner for your travelling and playing.
  • 【Bi-directional Transfer】This memory sd card reader supports batch uploading photos and videos to transfer to your iPhone/iPad/Mac/Camera, reducing waiting time , and also supports you to save the data from your mobile phone or computer to the SD card through the sd card reader.
  • 【Compatible with USB C】This USB C SD Card Reader for iPhone 15/15 Plus/15 Pro/15 Pro Max, 16,iPad Air 11 inch 4th /5th generation, iPad Pro 12.9 inch 6th /5th /4th /3rd generation, iPad Pro 11 inch 4th /3rd /2nd /1st generation, iPad Mini 6th generation, iPad 10th generation, MacBook Pro 13 inch 2020/2019/2018/2017/2016, MacBook 2017/2016/2015, MacBook Air 13 inch 2020/2019/2018, and other devices with USB C port and support OTG function.
  • 【Plug and play】This TypeC SD card reader compatible with MacOS, Windows, Linux, Chrome. No driver, does not require additional third -party software, plug-and-play, very convenient and portable. For iPad, you only need to use the iPadOS built-in "Files" app for import and export.
  • 【Compact Ports Friendly】The SD card adapter is the assistant of the photographer, allowing you to immediately view the best moment of the lens. Friendly and compact port design. With the built-in expansion USB-C cable of this SD card reader, you can save space and use ports side by side.

Choose the submission model that fits the UI

Use ordinary form submission if a navigation or reload is appropriate. Use JavaScript-managed FormData when the page should update in place or needs upload-specific interface behavior such as previews, progress, retry, or removal. React also supports a function passed as a form action, which receives form data; that API is distinct from the usual URL-valued HTML action. Check the React version and form architecture before choosing it. See React’s form reference.

Choose the right file-selection behavior

Single file or multiple files

Omit multiple when the user should pick one file. Add it when several selections are intended, then iterate through the returned FileList and submit each file in the format your backend expects. With FormData, multiple files can be appended under the same field name.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #3
Anker SD Card Reader USB C, Dual Slots USB Type C to Micro SD Card Adapter
  • Ultra-Compact: Use effortlessly next to other peripherals in your computer's USB port, or connect to your phone. Note: You may need to remove the case from your device before using this product.
  • Universal Compatibility: Optimized to work with a wide range of USB-C devices, like MacBook 2018, Galaxy S10, and more.
  • Better Than One: One standard and one microSD slot let you easily sync, swap, and share files.
  • USB-C On the Go: Use with your smartphone, wherever you are.
  • What You Get: USB-C 2-in-1 Card Reader, our worry-free 18-month warranty, and friendly customer service.

Use accept as a picker hint

The accept attribute takes a comma-separated list of extensions, MIME types, or broad types such as image/*. You can include both extensions and MIME types when useful for format aliases. For example, accept=".jpg,.jpeg,image/jpeg" guides the picker toward JPEG files.

accept is not validation. MDN states that it provides hints to help browsers guide users toward the expected file types; a user or browser may still allow another file to be selected. Validate uploads on the server, and do not treat a filename extension or client-provided MIME type as proof of a file’s contents.

Rank #4
Acer SD Card Reader USB C, 3 in 1 Memory Card Reader with Dual Slots/USB3.0
  • 【3-in-1 Card Reader】The USB C SD Card Reader features dual card slots and a USB 3.0 port, enabling simultaneous data transfer from SD, microSD, and USB devices at up to 5Gbps. Transfer photos, videos, and files fast—no need to swap devices(📌Note:Thick cases may prevent full insertion)
  • 【Versatile USB 3.0 Port】This Memory Card Reader is additionally equipped with a USB 3.0 port, which supports high-speed data transfer and can also seamlessly connect to USB A devices like wireless mouse/keyboard receivers, etc. (📌Note: Not compatible with “Lightning” and "USB-A" port devices)
  • 【Heat-Resistant & Portable】This SD Card Adpater features a durable aluminum shell for excellent heat dissipation and stable data transfers. Compact and lightweight, it fits easily in your pocket or bag. The 15cm cable keeps ports free—ideal for travel, remote shoots, or mobile work.(📌Note: "SD" card and "Micro SD" card not included)
  • 【Plug & Play】No drivers needed. Just connect your device to the micro SD Card Reader USB-C port and start transferring data instantly. Easy and convenient for laptops, tablets, and compatible smartphones. (📌Note: SD Slot does not support Type A/B/C Cards, CF, MS, Compact Flash, SDUC, UFS, credit, XQD and UHS-II Cards)
  • 【Wide Compatibility】 The Camera Adapter supports SD/Micro SD, SDHC, SDXC and other UHS-I cards. Also works with iPhone 17/16/15, MacBook Neo/Pro/Air, and other USB-C devices. Supports multiple systems such as Windows, macOS, Chrome OS, and Linux(📌Note: only reads and transfers data from the SD and TF card, not directly connect to the camera)

Use camera capture only when it is intentional

The capture attribute can request user-facing (user) or outward-facing (environment) camera or microphone capture for suitable media types. Availability and behavior depend on the browser and device, and a fallback may be used. Add it only when direct capture is part of the product requirement.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Keep the picker accessible and predictable

  • Associate every input with a visible label, either by nesting the input inside <label> or matching the label’s htmlFor to the input’s id.
  • Preserve keyboard access and native picker behavior when styling the control. If the native input is visually hidden, ensure users can still activate it by keyboard and that instructions and errors are programmatically associated with it.
  • Use a unique input ID for each component instance; useId can provide one.
  • Set button types deliberately inside forms: use type="submit" for the submit control and type="button" for buttons that should not submit.

React describes accessible input labeling and button behavior in its input reference.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Best Value
USB C SD Card Reader, Oyuiasle USB C to SD Card for iPhone 15 16/iPad/Mac/Laptop, USB-C/Type C Memory Card Adapter for iMac, iPad Pro Air Mini, MacBook Pro Air,Galaxy,MicroSD/SD
  • 【 Plug and Play】 This USB C SD card reader is designed with a built-in USB-C cord that won't block your other ports, no third party APP, no network, no driver, no extra power, two-way transfer, plug and play.
  • 【USB-C SD Card Reader 】 This USB-C SD card Adapter supports SD/Micro SD cards, let you to easily browse and copy photos and videos from your cameras, and quickly share your beautiful moments.
  • 【USB C to USB OTG Adapter 】 Support SD/Micro SD cards, but also compatible with all kind of cameras, flash drives, keyboard, mice, hard disk ,etc. Great convenience for you to transfer files between different devices.
  • 【 Widely Compatible 】 The USB C SD card reader compatible with iPad Pro 12.9-inch 6th Gen / 5th Gen / 4th Gen / 3th Gen, iPad Pro 11-inch 4th Gen / 3th Gen / 2th Gen / 1th Gen, iPad Air 11-inch 5th Gen / 4th Gen, iPad mini 6th Gen, iPad 10th Gen. And compatible with MacBook Pro/Air, iMac, Mac, Samsung Galaxy S10/S9/S8,Google Pixel and other different models of USB-C phones and tablets.
  • 【 Compatible with USB-C iPadOS/MacOS devices 】 This Type C SD card reader is compatible with iPhone 15/15 Plus/15 Pro/15 Pro Max/iPhone 16/16 Plus/16 Pro/16 Pro Max, iPad Pro/Air with a USB-C connector. You can easily transfer photos and videos to your iPad using iPadOS' built-in "Files" APP. It supports two-way transmission.

File input limitations and common mistakes

  • Do not set a selected path with value. The browser manages a file input’s selection, and script cannot populate it with an arbitrary local path. Keep selected File objects separately if the UI needs to render filenames or status.
  • Do not rely on accept for security. It guides selection but does not prove that an uploaded file is safe or of the claimed type; enforce file rules on the server.
  • Do not forget the field name. A named input is needed when collecting form fields through native submission or FormData constructed from the form.
  • Do not assume there is only one file. If multiple is enabled, handle every selected file and align the submitted field names with the backend contract.
  • Do not leave extra form buttons implicit. A button inside a form submits by default unless it has a different type.

The browser does not reveal the real local path in the input’s value; modern browsers may display a fake path prefix for compatibility. Consult MDN’s file input reference for picker behavior, cancellation, and path protections.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Outdated Drivers Are Slowing You DownFree scan - exact matches
Windows Errors? Fix Them Before They SpreadFree repair scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.