0

i am a having a html form with a upload field and i am trying to limit the user to upload only PDF file by using accept attribute, this seems to be working in crome but not in firefox, but w3c says it supports firefox also. i need it to support in firefox, is it possible?

 <input type="file" placeholder="Upload file"  name="file" id="file" accept="application/pdf" class="required" /> 
Aditya Kumar
  • 793
  • 1
  • 8
  • 14
  • This sort of validation should happen on the server side, if the client supports it, nice but don't count on it. – Madara's Ghost Aug 21 '12 at 12:42
  • Unfortunately, there's little you can do. Check [this article](http://techblog.procurios.nl/k/618/news/view/15872/14863/Mimetype-corruption-in-Firefox.html); it's a bit old, yes, but to my knowledge, it's still applicable. This [bug-thread](https://bugzilla.mozilla.org/show_bug.cgi?id=373621) might be helpful for understanding too. ) So, as others said, rely on the server-side check instead. – raina77ow Aug 21 '12 at 12:45
  • "but w3c says it supports firefox also" — Where? I'm not aware of any W3C resources that explain levels of browser support. – Quentin Aug 21 '12 at 12:45
  • 1
    `placeholder="Upload file"` suggests you need to read [about placeholders and labels](http://www.pardot.com/help/faqs/best-practices/placeholders-and-labels) – Quentin Aug 21 '12 at 12:46

3 Answers3

0

Check out the answer to this question: File input 'accept' attribute - is it useful?

Best not to use, or at the very least rely on the accept attribute.

Community
  • 1
  • 1
Gerald Versluis
  • 30,492
  • 6
  • 73
  • 100
0

In the w3schools the 'accept' attribute is not properly supported by some of the major browsers.The reason is the filter inside the file browser dialog will not work. so you must check some conditions like give file type is correct or not.It can be used for check JavaScript validation.

Ami
  • 4,241
  • 6
  • 41
  • 75
0

Try accept=".pdf"

<input type="file" name="file" id="file" accept=".pdf" class="required" />

DEMO: http://jsfiddle.net/dirtyd77/ZCDUe/

Dom
  • 38,906
  • 12
  • 52
  • 81