Skip to content

Instantly share code, notes, and snippets.

@nolanlawson
Created September 8, 2019 17:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nolanlawson/6fe0456c4b3996e69bbd1c2f11920d76 to your computer and use it in GitHub Desktop.
Save nolanlawson/6fe0456c4b3996e69bbd1c2f11920d76 to your computer and use it in GitHub Desktop.
Test iOS file types
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Test iOS audio input</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body>
<h1>Test iOS audio input</h1>
<div>
<label>
Accepts only audio:
<input type="file" accept="audio/*">
</label>
</div>
<div>
<label>
Accepts both audio and images:
<input type="file" accept="audio/*,image/*">
</label>
</div>
<div>
<label>
Accepts all file types:
<input type="file" accept="*/*">
</label>
</div>
<pre id="display"></pre>
<script>
(function () {
'use strict'
document.querySelectorAll('input').forEach(function (input) {
input.addEventListener('change', function (e) {
if (e.target.files && e.target.files[0]) {
var file = e.target.files[0]
document.getElementById('display').innerHTML += "File name: " + file.name + ", size: " +
file.size + '\n'
}
})
})
})()
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment