Form File

Customized, cross-browser consistent, file input control that supports single file, multiple files, and directory upload (for browsers that support directory mode).

Component reference

<b-form-file>

Component aliases

<b-form-file> can also be used via the following aliases:

  • <b-file>

Note: component aliases are only available when importing all of BootstrapVue or using the component group plugin.

Properties

All property default values are globally configurable.

Property
(Click to sort ascending)
Type
(Click to sort ascending)
Default
Description
accept
String''Value to set on the file input's `accept` attribute
autofocus
BooleanfalseWhen set to `true`, attempts to auto-focus the control when it is mounted, or re-activated when in a keep-alive. Does not set the `autofocus` attribute on the control
browse-text
String'Browse'Text content for the file browse button
capture
BooleanfalseWhen set, will instruction the browser to use the devices camera (if supported)
directory
BooleanfalseEnable `directory` mode (on browsers that support it)
disabled
BooleanfalseWhen set to `true`, disables the component's functionality and places it in a disabled state
drop-placeholder
String'Drop files here'Text to display as the placeholder when files are being dragged and it's allowed to drop them
file-name-formatter
FunctionMethod to format the file names for display. Refer to the docs for details
form
StringID of the form that the form control belongs to. Sets the `form` attribute on the control
id
StringUsed to set the `id` attribute on the rendered content, and used as the base to generate any additional element IDs as needed
multiple
BooleanfalseWhen set, will allow multiple files to be selected. `v-model` will be an array
name
StringSets the value of the `name` attribute on the form control
no-drop
BooleanfalseDisable drag and drop mode
no-drop-placeholder
String'Not allowed'Text to display as the placeholder when files are being dragged and it isn't allowed to drop them
no-traverse
BooleanfalseWether to returns files as a flat array when in `directory` mode
placeholder
String'No file chosen'Sets the `placeholder` attribute value on the form control
plain
BooleanfalseRender the form control in plain mode, rather than custom styled mode
required
BooleanfalseAdds the `required` attribute to the form control
size
StringSet the size of the component's appearance. 'sm', 'md' (default), or 'lg'
state
BooleannullControls the validation state appearance of the component. `true` for valid, `false` for invalid, or `null` for no validation state
value
v-model
Array or FilenullThe current value of the file input. Will be a single `File` object or an array of `File` objects (if `multiple` or `directory` is set). Can be set to `null`, or an empty array to reset the file input

v-model

Property
Event
valueinput

Slots

Name
Scoped
Description
drop-placeholder Placeholder content when files are about to be dropped. Defaults to value of `drop-placeholder` prop
file-name Scoped slot for formatting the file names
placeholder NoPlaceholder content, when no files selected. Defaults to `placeholder` prop value

Events

Event
Arguments
Description
change
  1. event - Native change event object
Original change event of the input
input
  1. file - Will be a single File object in single mode or an array of File objects in multiple mode
Updates the `v-model` value (see docs for more details)

Importing individual components

You can import individual components into your project via the following named exports:

Component
Named Export
Import Path
<b-form-file>BFormFilebootstrap-vue

Example:

import { BFormFile } from 'bootstrap-vue'
Vue.component('b-form-file', BFormFile)

Importing as a Vue.js plugin

This plugin includes all of the above listed individual components. Plugins also include any component aliases.

Named Export
Import Path
FormFilePluginbootstrap-vue

Example:

import { FormFilePlugin } from 'bootstrap-vue'
Vue.use(FormFilePlugin)