2

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.

2 Answers 2

1

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.

Sign up to request clarification or add additional context in comments.

Comments

1

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.

1 Comment

default value cant be set You cannot due to security reasons. i was looking for this <input type="file" accept="image/jpeg" />

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.