Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Input type file accept not showing PPS files

This is my upload input and no matter what I try it refuses the display Powerpoint PPS files.

It displays PDF, PPT, PPTX, PPSX but not PPS

    <input type="file"
    accept="application/pdf,application/vnd.ms-powerpoint,application/vnd.openxmlformats-officedocument.presentationml.slideshow,application/vnd.openxmlformats-officedocument.presentationml.presentation"
 name="upldInput"/>

The behavior is same in all the browsers, no one shows PPS files.

like image 627
user1615362 Avatar asked Mar 29 '13 17:03

user1615362


1 Answers

I can't find a MIME type that works. However, the following does work:

<input type="file" accept="application/pdf,.pps" name="upldInput"/>

Apparently you can mix and match file extensions and MIME types. On Chrome 25 and IE 10 (PC) this gives the desired behavior, i.e. only the matched MIME type(s) or extensions are shown.

Demo: http://jsfiddle.net/GGFVv/

I've also tried mixing multiple extensions and multiple MIME types, which also seems to work.

<input type="file" 
    accept=".pps,
    .jpg,
    .txt,
    application/pdf,
    application/vnd.ms-powerpoint,
    application/vnd.openxmlformats-officedocument.presentationml.slideshow,
    application/vnd.openxmlformats-officedocument.presentationml.presentation" name="upldInput"/>

Demo: http://jsfiddle.net/GGFVv/2/

I should note that file extension filtering does not seem to work in Firefox 19. I imagine this is because of the differences between the behavior defined by the W3C and the WHATWG.

  • W3C's definition of accept
  • WHATWG's description of how user agents should handle accept attribute

The original mention of accept (in 1995!) is somewhat vague:

Allow an ACCEPT attribute for INPUT tag, which is a list of media types or type patterns allowed for the input.

Firefox appears to default to "all files" when it finds a value it doesn't recognize, so this is somewhat user-friendly (though not ideal).

like image 195
Tim M. Avatar answered Nov 15 '22 08:11

Tim M.