Pages

Monday, 6 January 2020

Select specified file from input type file using HTML

Select specified file from input type file using HTML


Input type file enables you to select any type of file by default but you can specify which file type will be selected. Following HTML input type file enable you to select image (JPG,PNG),Word and PDF file. 



Without using accept attribute you will need to validate file by their extension which is very time consuming and prone to produce error So don’t validate file type with JS . Enjoy coding with Girfa Student Help.

<input type="file" class="upload" onchange="readURL(this)" id="fileNews" accept="image/x-png,image/jpeg,.doc, .docx,application/pdf" /><br />



No comments:

Post a Comment