3

enter image description here

I want to upload a .xlsx file to my systems with condition that the file name contains a specified string.

For example: I want to upload file whose name contains "Paper", so the file browser should not display files which don't contain "Paper" in their name.

For the example in the photo that I attached in this post, the file 'Order#...' should not be displayed.

How can i do it? Is it possible to implement this idea? thanks.

3 Answers3

5

You can use accept attribute
Try this code

<input type="file" accept="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" />

Read more here

Community
  • 1
  • 1
Divyesh Savaliya
  • 2,692
  • 2
  • 18
  • 37
1

Use accept attribute with input type file

<input type="file" name="my-file" id="" accept="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, application/vnd.ms-excel" >
0

You can use the accept attribute. Some older browser do not support it, but i think it is not an issue yet

The Bitman
  • 1,279
  • 1
  • 11
  • 25