The multiple attribute on an HTML5 file input enables users to pick more than one file through the File API, producing a FileList of File objects. Learn how to loop through the list, read properties like name, size, and type, and contrast with single-file behavior when the attribute is absent.

Multiple Choice

Which attribute enables selecting multiple files via the File API?

The ability to pick more than one file with the File API comes from the multiple attribute on the file input. This boolean attribute is simply present on the element, and its presence enables multi-file selection in the browser’s file picker. With multiple enabled, users can select several files at once (for example, by holding Ctrl or Shift while clicking or by dragging files into the picker, depending on the browser). Once files are selected, you access them through the input’s files collection, a FileList containing all chosen File objects; you can loop over it to read each file’s name, size, type, and so on. If the multiple attribute isn’t present, only a single file can be selected and the FileList will have just one File. The other attributes don’t enable multi-file selection: accept restricts which file types are allowed, disabled prevents interaction with the control, and required requires a value before submitting.

If you’ve ever built a file-upload feature for a website, you’ve probably run into a tiny but mighty HTML attribute: the one that lets users pick more than one file at once. It’s not flashy, but it changes how users interact with your page in a big, practical way. Think of it as giving the browser’s file picker a second gear. With a simple toggle, you transform a single-file experience into a multi-file flow, which can make a lot of sense for photo galleries, resumes, batch uploads, or any scenario where gravity pulls you toward efficiency.

Let’s start with the nuts and bolts. The File API lives in the input element when you set type="file". That’s the obvious doorway to letting users bring files into your web app. The real magic for multi-file selection is the presence of the multiple attribute on that same input element. It’s a boolean attribute—its mere presence is what matters. No value, no fuss. If you include multiple, the browser’s file picker invites the user to select more than one file. If you omit it, the picker stays stubbornly single-file. It’s a small switch, but it changes the user’s journey.

Why does this matter? Because in a real-world interface, the ability to pick multiple files at once can dramatically reduce friction. Imagine uploading a folder’s worth of photos from a vacation, or a handful of PDFs for a project, or even a stack of audio files for a playlist. The user doesn’t have to repeat the process, file after file. They can select several at once, and your code can handle them as a batch. That’s where the FileList comes in—the input element’s files property provides a FileList, an array-like collection of File objects that represent the user’s selections. Each File object carries essential details: name, size, type, and lastModified. You can loop over that collection to display a quick summary, preview thumbnails, or show progress as you read each file.

If you’re curious about how that works behind the scenes, here’s a straightforward walkthrough. When a user chooses files through the input, the browser populates the input’s.files property with a FileList. If the multi attribute is present, that FileList can contain multiple File objects. Your code then iterates over this list, reading properties like file.name, file.size, and file.type. If the user happens to pick a bunch of images, you can generate previews by reading the file data with a FileReader or by extracting metadata. The important point is that the multi attribute is what allows that multi-file FileList to exist in the first place.

A quick aside on a small but common pitfall: you might wonder about restricting which file types are allowed. That’s where the accept attribute comes into play. It doesn’t enable multi-file selection by itself, but it guides the user toward choosing only certain kinds of files. For example, accept="image/*" tells the browser to filter the picker to images. This helps prevent user frustration when you’re expecting, say, PNGs or PDFs. The accept attribute is a helpful companion, but it isn’t the mechanism that enables multiple selections. That job belongs to the multiple attribute.

Another bit to keep in mind: the disabled and required attributes. The disabled attribute simply keeps the control from being used. It’s like locking a door, useful when you want to wait for something else to happen before uploads are allowed. The required attribute, on the other hand, ensures a value is present before form submission. It doesn’t affect how many files the user can pick; it just changes submission behavior. When you’re designing a user flow, you might combine these with multi to control both how many files you collect and when you allow the submission to proceed.

Let’s talk about the experience from the user’s perspective. Multi-file selection can feel empowering; it reduces back-and-forth and mirrors real-world needs. People often hold down Ctrl (or Cmd on macOS) or Shift to select a range, or they simply drag-and-drop into the file picker. The browser’s file input becomes a mini workspace, letting users assemble a batch instead of piecemeal uploading. And if you pair this with a nice preview pane, users get immediate feedback—“Yep, those are the files I intended to upload.” It’s little moments like these that transform a mundane task into a smooth interaction.

But the journey doesn’t end with selecting files. The next steps—reading, validating, and uploading—deserve thoughtful handling. With multiple files in play, you’ll likely loop through input.files and process each File object. If you’re showing progress, you might read files with a FileReader or upload them in chunks with fetch or XMLHttpRequest. You can also implement per-file validation: check file.type for the right MIME types, verify file.size doesn’t exceed limits, or enforce a maximum number of files to keep things sane on the server side. The key is to keep developers and users aligned: clear feedback, consistent behavior, and a predictable flow from selection to completion.

A few practical tips that can save you grief in real projects:

  • Be explicit about fallback behavior. Not all browsers handle File API flawlessly, especially older ones. Have a graceful fallback—maybe a single-file input or a clear message—so users aren’t left staring at a broken experience.

  • Provide helpful defaults and hints. If you expect images, you might show a compact preview gallery. If PDFs are your thing, give a quick document icon plus file name and size. Visual aids reduce cognitive load and speed up decisions.

  • Offer drag-and-drop as a companion. For many people, dropping files onto a designated area feels more natural than clicking a button. A well-implemented drop zone can complement the multi attribute nicely, though it does add a touch of extra code to handle events like dragover and drop.

  • Think about accessibility. Keyboard users should be able to activate the file picker as easily as mouse users. Ensure focus states are visible and ARIA attributes, where appropriate, keep things navigable.

  • Validate on the client-side, then re-validate on the server. Client-side checks feel snappy, but never rely on them alone. Server-side validation is the final guardrail to ensure data integrity and security.

If you’re building a modern UI, you might pair multi-file selection with a progressive enhancement approach. Start with a simple, reliable, single-file upload for the widest compatibility. Then, progressively reveal multi-file support for browsers that can handle it. That way, you honor users who may be on older devices while still delivering a richer experience where possible.

Let me explain with a quick mental model. Imagine the file input as a mailbox. The multiple attribute is the moment you decide you’re allowing multiple letters at once, not just one. The letters are the File objects—the contents your app will eventually read. You, the builder, stand at the curb with a tag reader, ready to inspect each parcel as it arrives. Some days you’ll get a single letter; other days a small parcel stack. The code you write to handle that FileList is your route map for processing, validating, and showcasing what’s been received.

As you get comfortable with multi-file uploads, you’ll notice a few patterns emerge. Consistency becomes the anchor. If you allow multiple files in one action, you usually want to present a consistent summary: a list of file names, sizes, and types, plus a simple progress indicator for uploads. Users appreciate transparency—knowing which files are in the queue, how many are left, and whether any have failed. That clarity reduces anxiety and improves overall satisfaction with the feature.

From a developer’s perspective, it’s also a chance to leverage the broader ecosystem. Modern frameworks and libraries often have helpers for File API operations, easing tasks like reading file contents, generating previews, and streaming data to the server. You’ll encounter familiar patterns—event listeners on input change, FileReader callbacks, and asynchronous fetch calls—that feel like old friends by the time you’ve built a handful of projects around them. The mental model is straightforward: you respond to a user action, gather File objects, validate, and then push them toward the next stage of your application’s workflow.

If you’re new to this, there’s a reassuring simplicity here. The multiple attribute is a binary choice with a clear impact: it toggles the scope from one file to many. The rest unfolds from there—how you present the list, how you validate, and how you actually transmit the files. It’s a piano with a few keys, and once you’ve learned the keys, you can improvise a lot without losing the melody.

A short note on accessibility, because good design should feel inclusive. The multi attribute doesn’t complicate focus order or labeling by itself, but with multiple files in play, you might think about how you label the input and how you describe the behavior. A concise instruction like “Select multiple files by holding Ctrl/Cmd or Shift, or drag them here” helps users who are navigating with screen readers or who are new to file uploads. Clear, human language goes a long way in creating an frictionless experience.

In the end, the multiple attribute is a simple toggle that unlocks a more flexible, efficient way to collect user files. It’s not about fancy features or arcane tricks; it’s about meeting people where they are and letting the browser do the heavy lifting with a little guidance from you. When you wire this into a thoughtful UI with previews, progress, and robust validation, you’ve built a small but meaningful improvement to the way users interact with your site.

So next time you’re structuring an upload form, consider this: do you want a single-file ritual, or a multi-file workflow? If the answer is multi, the multiple attribute is your friend, quietly doing its job while you focus on the bigger picture—creating an experience that’s smooth, intuitive, and a tad delightful. And that, in the end, is what keeps users coming back for more.