0

Works fine in most browsers accept...

OS X 10.7.5 - Firefox 30.0 + Safari 6.1.5

Here is the HTML:

<input id="fileupload" type="file" name="files[]" data-url="/do/upload_my_files" accept=".pdf,.docx,.doc,.xls,.xlsx,.txt,.csv,.ppt,.pptx,.zip,.rar,.psd,.txt,.pps,image/*" multiple>

It shows only images available to select, all other files are greyed out.

2 Answers 2

6

The HTML 4.01 specification allows only media types (MIME types) in the content of an accept attribute. HTML5 extends this with notations like .pdf. Browsers that do not support the latter see your attribute just as accept="image/*">. Thus, add the media types (when available) such as application/pdf to the list, primarily using the authoritative media type list by IANA. If this does not help, you are probably out of luck and should perhaps remove the attribute, if the browsers that don’t cope with it are important enough.

1
  • Is there a shim or anything I can use to hack it? :)
    – chris
    Aug 15, 2014 at 8:31
2

I had this same issue and found that while Safari will not accept the comma-separated extensions, you can actually use the previously mentioned IANA list to address most types, including MS Office files (which is what I needed):

.doc/.docx: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet

.xls/.xlsx: application/vnd.openxmlformats-officedocument.wordprocessingml.document

.ppt/.pptx: application/vnd.openxmlformats-officedocument.presentationml.presentation

It is working for me in both Chrome and Safari (6+). The IANA list doesn't make it easy to find what you need, but there is a handy list at freeformatter.com that tells you exactly what to use for each extension.

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.