Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1014341
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T10:14:20+00:00 2026-05-16T10:14:20+00:00

<input type=’file’ name=’userFile’> now when i will click the browse button, the browse dialog

  • 0
<input type='file' name='userFile'>

now when i will click the browse button, the browse dialog will show all files… what if i want to filter file types lets say

  • only images or .png & .jpg & .gifs
  • only office file like .doc & .docx & .pps

how to do it…

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T10:14:21+00:00Added an answer on May 16, 2026 at 10:14 am

    There is an “accept” attribute on file input controls, where you can specify the types of files you want. From what i’m seeing, though, many browsers like to ignore it — the file types that can be specified are MIME types, so a strictly correct browser would have to look at every file regardless of extension and see if it’s an image (and if so, what type it is).

    Update: It seems at least some version of every major browser on Windows now provides at least some support for the accept attribute. (Even IE supports it, as of version 10.) However, it’s still a bit early yet to rely on it, as IE 8 and 9 still don’t support it. And support in general is a bit spotty.

    • Chrome seems to have full support. It uses its own built-in list of types as well as the system’s…so if either one defines the type, Chrome knows which files to show.
    • IE 10 supports file extensions beautifully, and MIME types decently. It seems to use only the system’s mapping of MIME type to extensions, though…which basically means if something on the user’s computer didn’t register those extensions with the right MIME types, IE won’t show files of those MIME types.
    • Opera only seems to support MIME types — to the point where extensions actually disable the filter — and the UI for the file selector sucks. You have to select a type in order to see the files of that type.
    • Firefox appears to support only a limited set of types, and ignore other types as well as extensions.
    • I don’t have Safari, and don’t plan on downloading it. If someone could document Safari’s support… Partial support on safari. http://caniuse.com/#search=accept

    You should consider adding the attribute, so browsers that support it can help the user find the right files more easily. But i would still suggest that you check the filename after the file’s selected and show an error message if a file with the wrong extension is uploaded.

    And of course, definitely have the server double-check that the file is the right type. File extensions are just a naming convention, and can be easily subverted. And even if we could trust the browser (which we can’t), and even if it did attempt to filter stuff as you asked (which it might not), the chance of it actually verifying that that .doc file is truly a Word document is next to nil.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

No related questions found

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.