abhijit
abhijit

Reputation: 1968

Setting default file types for the html input:file

Can I set default file types association for HTML file input? E.g. just .jpg,.bmp/.png with the HTML input control? When browse is clicked the dialog should show just show all those associated filetypes not allfiles that usually occurs.

Upvotes: 2

Views: 917

Answers (2)

BalusC
BalusC

Reputation: 1109412

The accept attribute of the HTML <form> element is meant for that, but this optional attribute is ignored by almost all webbrowsers. The answer is Flash or Java Applet. For both there exist 3rd party file upload plugins. E.g. Uploadify, SWFUpload and JumpLoader. Uploadify has my recommendation.

Upvotes: 1

Oded
Oded

Reputation: 499252

No, this is not possible.

One a user selects a file you can check the file type (extension) in javascript and decide on the basis of that whether to post the form or not.

However, since javascript can be subverted or turned off, you will have to check server side for the file types you allow, just to be certain.

Upvotes: 1

Related Questions