Dynamically Changing multiple/Single File Selection in the Upload Box

In order to change the upload box selection type dynamically,
 
we need to add the upload element attribute "multiple", and if we want to make the single file selection we have to remove the attribute "multiple".
  1. <span>Sample File Selection</span><br/>    
  2.    <input type="file" name="One" id="SampleFileUpload"/><br/><br/><br/>    
  3.    <br/>    
  4. <span>Multiple file selection</span><input type="checkbox" id="Mutiple"><br/>    
  5. <button id="change" onclick="Change()" >Change Single/Multiple file select upload</button>    
Script for changing dynamically:  
  1. function Change()  
  2. {  
  3.    if(document.getElementById("Mutiple").checked)  
  4.    document.getElementById("SampleFileUpload").setAttribute("multiple","sample");  
  5.    else  
  6.    document.getElementById("SampleFileUpload").removeAttribute("multiple");  
  7.   
  8. }   
 
Ebook Download
View all
Learn
View all