EN
HTML - form input file only for mp3
0
points
In this article, we would like to show you how to create file input only for mp3 files in HTML.
Quick solution:
// ONLINE-RUNNER:browser;
<input type="file" accept="audio/mpeg" />
Practical example
In this example, we create file input using type="file" attribute. To make it allow only mp3 files, we set accept attribute to the types that file input should accept.
// ONLINE-RUNNER:browser;
<!doctype html>
<html>
<body>
<label>
<span>Choose a file:</span>
<input type="file" name="audio" accept="audio/mpeg" />
</label>
</body>
</html>