Skip to content

Inputs

FileInput

Bit.BlazorUI

BitFileInput lets the user hand files to the app - through the file dialog, by dropping them onto it or by pasting them - without uploading anything. Each file surfaces in C# as a BitFileInputInfo (name, size, type, folder and, on request, image dimensions) and is validated on arrival against size, total size, type, count, duplicate and custom rules; a rejected file stays in the list with its reason. Content is read on demand, as a byte array or a stream. A drop zone panel, thumbnails, type glyphs, remove buttons, templates and screen reader announcements are built in. To send files to a server, use BitFileUpload.

Selection & limits

Removing files, appending to the list and duplicates, size and count limits, accepted types and camera capture, and custom validation.

Removable

ShowRemoveButton adds a remove button to each file, raising OnRemove and OnFilesChange. The focus moves on to the next remove button, or back to the browse button, so files can be removed in a row from the keyboard. RemoveButtonIconName swaps the icon.


Append, AutoReset & duplicates

A new selection replaces the list by default. Append adds to it instead and AutoReset empties it right before the dialog opens. With AllowDuplicates off, a file already in the list (same folder, name, size and modified time) is marked invalid with the DuplicateErrorMessage - pick the same file twice to see it.

Append with no duplicates:



AutoReset:

Size & count limits

MaxSize and MinSize bound each file, MaxTotalSize the whole list and MaxCount the number of files. A rejected file stays in the list, marked invalid with its ...ErrorMessage. The list-level limits are re-run on every change, so removing files frees their room again.

Per file, 1 MB max and 1 KB min, with a custom message:



Up to 3 files and 2 MB in total:

Accept, AllowedExtensions & Capture

Accept only filters the file dialog - drops and pastes bypass it. AllowedExtensions validates every file however it arrived and generates the accept attribute when Accept is not set. Its entries ignore case and the leading dot, and an entry with a slash is a MIME type, wildcards like image/* included.

Accept (dialog filter only):



AllowedExtensions (validated) - extensions, with or without the dot, and a MIME type:



Capture asks a mobile device for a camera or a microphone instead of the file browser - "user" for the front camera, "environment" for the rear one - with an Accept saying which. Desktop browsers ignore it.

Custom validation

FileValidator runs after the built-in checks: return a message to reject the file or null to accept it; a validator that throws only rejects its own file. ReadImageDimensions decodes images first to fill Width and Height for resolution rules - opt-in, since decoding costs time and memory.

Rejecting empty files:



Rejecting images below 300×300:

Feedback

Found a mistake, a gap, or something that could be clearer? Every page and every component is one click from its source.