Posted on: September 03, 2021 09:48 AM
Posted by: Renato
Views: 419
HTML Valid Accept Types
Valid Accept Types:
For CSV files (.csv), use:
For Excel Files 97-2003 (.xls), use:
For Excel Files 2007+ (.xlsx), use:
For Text Files (.txt) use:
For Image Files (.png/.jpg/etc), use:
For HTML Files (.htm,.html), use:
For Video Files (.avi, .mpg, .mpeg, .mp4), use:
For Audio Files (.mp3, .wav, etc), use:
For PDF Files, use:
DEMO:
http://jsfiddle.net/cpdrenato/4qxzhwo5/1/
NOTE:
If you are trying to display Excel CSV files (.csv
), do NOT use:
text/csv
application/csv
text/comma-separated-values
(works in Opera only).
If you are trying to display a particular file type (for example, a WAV
or PDF
), then this will almost always work...
Dom this attribute is very old and not accepted in modern browsers as far as I know, But here is an alternative to it, Try this
I guess it'll help you of course you can change this script according to your needs.
<script type="text/javascript" language="javascript">
function checkfile(sender) {
var validExts = new Array(".xlsx", ".xls", ".csv");
var fileExt = sender.value;
fileExt = fileExt.substring(fileExt.lastIndexOf('.'));
if (validExts.indexOf(fileExt) < 0) {
alert("Invalid file selected, valid files are of " +
validExts.toString() + " types.");
return false;
}
else return true;
}
</script>
......
<input type="file" accept=".csv" />
<input type="file" accept="application/vnd.ms-excel" />
<input type="file" accept="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" />
<input type="file" accept="text/plain" />
<input type="file" accept="image/*" />
<input type="file" accept="text/html" />
<input type="file" accept="video/*" />
<input type="file" accept="audio/*" />
<input type="file" accept=".pdf" />
Donate to Site
Renato
Developer