Javascript DOM HTML Input FileUpload accept multiple content types set

Introduction

Accept multiple content types:

// The server will only accept audio and video files in the file upload 
document.getElementById("myFile").accept = "audio/*,video/*";

Click the button below to specify that the server should only accept audio and video files in the file upload.

View in separate window

<!DOCTYPE html>
<html>
<body>

Select a file to upload:
<input type="file" id="myFile" size="50">
<button onclick="myFunction()">Change accepted file types</button>

<p id="demo"></p>

<script>
function myFunction() {/*from w w w  . j av a2s.c o m*/
  document.getElementById("myFile").accept = "audio/*,video/*";
  document.getElementById("demo").innerHTML = "The accepted file types have been set.";
}
</script>

</body>
</html>



PreviousNext

Related