question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

b-form-file issue with "accept" values - in "multiple" mode

See original GitHub issue

Link to JSFiddle

I found what to me looks like a strange behaviour of b-form-file component. I set an instance of b-form-file to support selecting multiple files, and specified accept MIME types, exactly like it’s shown in the docs (just skipped the image/gif type):

<b-file v-model="files" multiple accept="image/jpeg, image/png"></b-file>

But when dropping any files (single or multiple) on the input doesn’t update the model - the component simply ignores all the files, even valid ones. When picking files manually, instead of dropping them, the non-accepted files are disabled in the browser file select dialog (in Chrome), so that’s OK. But then again - choosing any JPG or PNG file doesn’t update the model, and the event emitted by the component has an empty payload.

b-form-file still behaves as expected when not in “multiple” mode.

OS: macOS High Sierra Browsers: Chrome 63, Firefox 57 Bootstrap: 4.beta-2 BootstrapVue: 1.4.0

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:13 (1 by maintainers)

github_iconTop GitHub Comments

3reactions
JackEggiecommented, Sep 27, 2018

I guesse the problem in bootstrap-vue/src/components/form-file/form-file.vue

Line 299 in 142d517

                 if (files[i].type.match(this.accept)) {

String.prototype.match() takes the parameter this.accept as regex.

@mmieluch Therefore, the comma in your accept prop can’t be parsed by regex.

And I agree to @Diaskhan‘s opinion, String.prototype.match() is a misusage here.

1reaction
tomattoscommented, Sep 5, 2018

we can pass the regular expression into accept property and it will work properly Example: <b-form-file :accept="image/png|image/jpeg|image/jpg|text/plain" multiple plain></b-form-file>

Read more comments on GitHub >

github_iconTop Results From Across the Web

Form File | Components - BootstrapVue
Customized, cross-browser consistent, file input control that supports single file, multiple files, and directory upload.
Read more >
Form File | Components | BootstrapVue
Customized, cross-browser consistent, file input control that supports single file, multiple files, and directory upload.
Read more >
vue.js - <b-form-file> does not keep the filename visible when ...
When I visit another component(Component1.vue) via the UI and come back to Component2.vue, the filename is not visible in the browse anymore.
Read more >
B- form- file vue bootstrap - Weebly
Multiple files Upload multiple files supports adding more prop components. ... about MDN Directory mode is not supported if the file input is...
Read more >
bootstrap-vue - UNPKG
src/components/input-group/input-group-prepend.js",". ... Checks if there are multiple instances of Vue, and warns (once) about possible issues.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found