Search code examples
modernizrinput-type-file

Does modernizr distinguish between image and file system access?


I'm using Modernizr 3.0 to check for input[type='file'] so I don't show an upload button to users who can't use it. I'm worried that Modernizr.fileinput will return false for users who don't have file system access but do have camera access via

<input type="file" accept="image/*" />

I've tried checking this on browserstack but I'm still uncertain because I don't know how the various cameras respond on their VMs.

Does Modernizr distinguish between no file system access and no camera access or will Modernizr.fileinput return false if the user doesn't have file system access but does have camera access?


Solution

  • You can use Modernizr.filesystem in conjunction with Modernizr.fileinput to see if the user has file system access.

    Most desktop browsers support filesystem API, but mobile browsers don't. A weaker check would be Modernizr.filereader but it'll work on most mobile browsers (barring older ones such as IE9 and old Androids).