Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Multiple File Options When Upload File in Input Accept Attribute

Tags:

I want to show multiple file type option when upload the files.

I refer to this: http://jsfiddle.net/dirtyd77/LzLcZ/144/ .

It works great when only one type of file is appear on the option.

<p>Only show Excel (.xlsx) files...</p> <input type="file" accept="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" ID="fileSelect" runat="server" />   

but it will show 'Custom Files' when it has multiple options. as shown in image below.

<p>Show .xls, .xlsx, .csv files...</p> <input type="file" accept=".csv, .pdf" ID="fileSelect" runat="server" />   

enter image description here

Is there any way to show multiple options (1row for PDF, 1row for image, 1row for Excel, etc) in the file type dropdown menu? Instead of showing 'Custom Files'?

like image 648
hahahaha Avatar asked Sep 04 '15 06:09

hahahaha


People also ask

How do you accept an attribute in a file upload?

The accept attribute specifies a filter for what file types the user can pick from the file input dialog box. Note: The accept attribute can only be used with <input type="file"> . Tip: Do not use this attribute as a validation tool. File uploads should be validated on the server.

How do you input multiple files?

Tip: For <input type="file"> : To select multiple files, hold down the CTRL or SHIFT key while selecting. Tip: For <input type="email"> : Separate each email with a comma, like: [email protected], [email protected], [email protected] in the email field.

Why do you think it's best to include the accept attribute in an input type file?

The accept attribute is incredibly useful. It is a hint to browsers to only show files that are allowed for the current input .

Which type of input tag allows multiple selection?

HTML | <input> multiple Attribute The HTML <input> multiple Attribute is a Boolean Attribute. It specifies that the user is allowed to select more than one value that presents in an element.


1 Answers

hi i have tried this and worked

the problem was the space you have given between the .csv, .pdf as i thought

<p>MY CUSTOM ONE</p>  <input type="file" accept="image/*,video/*,.pdf,.csv" ID="fileSelect" runat="server" />  

here is your updated fiddle work

DEMO code working

like image 130
Himesh Aadeshara Avatar answered Nov 02 '22 13:11

Himesh Aadeshara