@@ -6,15 +6,13 @@ multiple files, and directory upload (for browsers that support directory mode)
6
6
``` html
7
7
<template >
8
8
<div >
9
- <!-- Simple File -->
10
- <b-form-file id =" file_input1" v-model =" file" ></b-form-file >
11
- <br > Selected file: {{file && file.name}}
12
-
13
- <div class =" mt-3" >
14
- <!-- Customized labels -->
15
- <b-form-file id =" file_input2" v-model =" file2" choose-label =" Attachment2" ></b-form-file >
16
- <br > Selected file : {{file2 && file2.name}}
17
- </div >
9
+ <!-- Styled -->
10
+ <b-form-file v-model =" file" placeholder =" Choose a file..." ></b-form-file >
11
+ <div class =" mt-3" >Selected file: {{file && file.name}}</div >
12
+
13
+ <!-- Plain mode -->
14
+ <b-form-file v-model =" file2" class =" mt-3" plain ></b-form-file >
15
+ <div class =" mt-3" >Selected file: {{file2 && file2.name}}</div >
18
16
</div >
19
17
</template >
20
18
@@ -36,20 +34,17 @@ For cross browser consistency, Form file defaults to the Bootstrap custom file
36
34
input to replace the browser defaults. They’re built on top of semantic and accessible
37
35
markup, so it is a solid replacement for the default file input.
38
36
39
-
40
37
## Single file (default)
41
38
On single file mode, when no file is selected or user cancels Browse dialog, ` v-model ` is ` null `
42
39
indicating no file selected. When a file is selected the return value will be a javascript
43
40
[ ` File ` ] ( https://developer.mozilla.org/en/docs/Web/API/File ) object instance.
44
41
45
-
46
42
## Multiple files
47
43
Multiple file uploading is supported by adding ` multiple ` prop to component.
48
44
In this case ` v-model ` is * always* an ` Array ` . When no files are selected, an empty array
49
45
will be returned. When a file or files are selected the return value will be an array of
50
46
javascript [ ` File ` ] ( https://developer.mozilla.org/en/docs/Web/API/File ) object instances.
51
47
52
-
53
48
## Directory mode
54
49
By adding ` directory ` prop, the user can select directories instead of files.
55
50
When a directory is selected, the directory and its entire hierarchy of contents are included in the set of selected items.
@@ -59,11 +54,9 @@ The selected file system entries can be obtained using the `webkitEntries` prope
59
54
be relied for production.
60
55
[ Read more on MDN] ( https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/webkitdirectory )
61
56
62
-
63
57
## Drag and Drop
64
58
Drop mode is enabled by default. it can disabled by setting the ` no-drop ` prop.
65
59
66
-
67
60
## Limiting to certain file types
68
61
You can limit the file types by setting the ` accept ` prop to a string containing the
69
62
allowed file type(s). To specify more than one type, separate the values with a comma.
@@ -87,34 +80,19 @@ list of standard media types.
87
80
88
81
** Note:** Not all browsers support or respect the ` accept ` attribute on file inputs.
89
82
90
-
91
- ## Customizations
92
- Language strings and chosen file name is injected using ` data- ` props to css ` content ` .
93
- Local customization can be easily done with provided props such as ` placeholder ` ,
94
- ` choose-label ` , ` selected-format ` and ` drop-label ` . If you want to globally change
95
- labels, you can add something like this to your global stylesheets. Also it is advised
96
- to use [ : lang ()] ( https://developer.mozilla.org/en-US/docs/Web/CSS/:lang ) for multi-language sites.
83
+ ## Customize browse label
84
+ If you want to globally change ` Browse ` label, you can add something like this to your global stylesheets.
85
+ Also it is advised to use [ : lang ()] ( https://developer.mozilla.org/en-US/docs/Web/CSS/:lang ) for multi-language sites.
97
86
98
87
``` css
99
- /* Globally localize BootstrapVue file upload labels */
100
-
101
- .custom-file-control ::after {
102
- content : ' No files selected' !important ;
103
- }
104
-
105
- .custom-file-control ::before {
106
- content : ' Choose file' !important ;
107
- }
108
-
109
- .custom-file .drop-here ::before {
110
- content : ' Drop files here' !important ;
88
+ .custom-file-input :lang (en )~ .custom-file-label ::after {
89
+ content : " Browse" ;
111
90
}
112
91
```
113
92
114
93
## Non custom file input
115
94
You can have ` <b-form-file> ` render a browser native file input by setting the ` plain ` prop.
116
95
117
-
118
96
## Contextual state feedback
119
97
Bootstrap includes validation styles for ` valid ` and ` invalid ` states
120
98
on most form controls.
@@ -129,7 +107,6 @@ and want to encourage a user through the rest of the fields.
129
107
To apply one of the contextual state icons on ` <b-form-file ` , set the ` state ` prop
130
108
to ` 'invalid' ` (or ` false ` ), ` 'valid' ` ( or ` true ` ), or ` null ` .
131
109
132
-
133
110
## Accessibility
134
111
When using the custom version of ` <b-form-file> ` input which hides the original input, it is
135
112
** highly recommended** that you supply a document unique ID string via the ` id ` prop. This will
@@ -168,10 +145,8 @@ window.app = new Vue({
168
145
})
169
146
```
170
147
171
-
172
148
## Component alias
173
149
174
150
` <b-form-file> ` can be used via the shorter component alians ` <b-file> ` .
175
151
176
-
177
152
## Component Reference
0 commit comments