Reputation: 867
Can I use filter for <input type="file" accept=""/>
with file name prefix/suffix ? For example for '_32' suffix will filter files from Fig-A to Fig-B.
Upvotes: 1
Views: 2151
Reputation: 944013
No.
The accept attribute only accepts MIME types and file extensions.
It cannot match on other parts of the filename.
You could use JavaScript to read the filename and show an error if poor choice of file is selected.
document.querySelector('input').addEventListener("input", function () {
if (this.files[0].name.match(/_32\..{3,4}$/)) {
console.log("OK");
} else {
console.log("Not OK");
}
});
<input type="file">
Upvotes: 4