Reputation: 61
I'm trying to allow only .tsv files visible for upload. It's a valid MIME Type, so I'm not sure why it isn't working. Can you help?
<input type="file" accept="text/tab-separated-values" />
Upvotes: 0
Views: 1289
Reputation: 53
hmm check out this link just to be sure that your mime type is correct
Upvotes: 1
Reputation: 3456
You can try with javascript.
<script type="text/javascript" language="javascript">
function checkfile(inputVal) {
var validExts = ".tsv";
var fileExt = inputVal.value;
fileExt = fileExt.substring(fileExt.lastIndexOf('.'));
if (validExts.indexOf(fileExt) < 0) {
alert("Invalid file selected. ");
return false;
}
else return true;
}
</script>
Upvotes: 1
Reputation: 175
The Mime-Type tells the server which protocol to use to process the information given. I've always done this as validation on the server side by only accepting file name(s) that end with .tsv
If you do not want to do this server side, you can write some javascript to look at the value of the input field before you submit to make sure it ends with .tsv
Upvotes: 0