Comments (6)
You can do this through normal input settings adding the accept
attribute to the input with type set to file.
accept=".doc,.docx,application/msword,application/vnd.openxmlformats-officedocument.wordprocessingml.document"
and for a full example
<div class="custom-file">
<input
type="file"
class="custom-file-input"
id="inputGroupFile04"
accept=".doc,.docx,application/msword,application/vnd.openxmlformats-officedocument.wordprocessingml.document"
multiple
aria-describedby="inputGroupFileAddon04">
<label class="custom-file-label" for="inputGroupFile04">Choose file</label>
</div>
from bs-custom-file-input.
There would be two layers that you would need to check. First being your front-end, which you can do with the provided example or by writing some code that can check the file types and prevent uploading.
The other layer would be your server, after receiving the file that is acceptable. otherwise you could return some kind of server response to your front-end.
from bs-custom-file-input.
Hi @Leenshady, it's not the purpose of this plugin and as @jessycormier said it's not a good practice to do that only on the front side.
BTW thanks for using my plugin and thanks @jessycormier for answering 👍
from bs-custom-file-input.
Thank you for your reply. I'm sorry for my misrepresentation. I mean when I submit a file of the wrong type, there will be friendly prompts.
from bs-custom-file-input.
I'm not familiar with the front end. If my requirement are wrong, please don't hit me, hahahaha
from bs-custom-file-input.
So I can't do this only on the front-end,right?thank you very much!
from bs-custom-file-input.
Related Issues (20)
- Missing export HOT 2
- disable drag & drop?
- Implementation with multiple file pickers on the same form
- Remove Source-Maps for Production Builds
- Doesn't work with bootstrap 5 HOT 1
- Is it a problem if we call bsCustomFileInput.init() again after an ajaxSuccess event? HOT 2
- `destroy` should be able to specify a specific element, not wipe out the entire documents custom ones
- Label text overflows when uploading multiple files in iOS Safari HOT 1
- Bootstrap v5 compatibility HOT 1
- Add Bootstrap 5 support HOT 2
- Label descendants are removed or "concatenated" HOT 1
- When to call bsCustomFileInput.init() in a react app (when using in a Modal dialog)?
- How to use if( typeof $.fn.filestyle!== 'undefined' && $.isFunction($.fn.filestyle) ){
- How to remove selected file? HOT 3
- Drag and drop doesn't work if character size is changed in Safari
- Display number of items instead of their name on multiple inputs HOT 2
- Not able to make this work - no filename. Script and HOT 1
- ReferenceError: window is not defined
- Feature: file size validation
- Support Bootstrap 5 HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from bs-custom-file-input.