2

I want to filter files user can select into <input type='file'>

So I wrote : <input class="form-control" accept="video/*" name="my_video" id="my_video" type="file"> for video

and <input class="form-control" accept="image/*" name="my_picture" id="my_picture" type="file"> for an image

I do tests with Linux browsers :

  • Firefox 53.0 (64 bits)
  • Chromium 58.0.3029.81 (64-bit)

both do not filter file types.

I looked around on stackoverflow. Syntax seems good. But even examples from that discussion does not work for me.

I checked on MDN as well. Nothing to help me.

I also tried to put directly file extension like accept="png" accept=".png", accept="*.png". With same result.

Does someone have a clue to make accept parameter work?

Community
  • 1
  • 1
mickro
  • 881
  • 2
  • 11
  • 26

1 Answers1

0

Code is too simple and it shows no error on Chrome. But for cross-browser functionality you can use jquery code or Bootstrap File Input

  • What do you mean by "too simple" ? The code works as file input field. Only the filter part does not. – mickro Apr 30 '17 at 10:21
  • Thanks for bootstrap link, that mainly helps to make pretty input fields. Anyway [the code behind](http://plugins.krajee.com/file-image-dimensions-demo) looks very similar as mine. – mickro Apr 30 '17 at 10:25