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 HT开发者_运维百科ML input control? When browse is clicked the dialog should show just show all those associated filetypes not allfiles that usually occurs.
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.
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.
精彩评论