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 5949339
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T17:14:09+00:00 2026-05-22T17:14:09+00:00

I have a file input with the multiple=multiple attribute to allow users to select

  • 0

I have a file input with the multiple="multiple" attribute to allow users to select multiple files at once. I would like to display selected file names and their count prior to upload however I’m not sure how to get this information from file input element using javascript?

<input type="file" id="fileElementId" name="files[]" size="20" multiple="multiple" />

I’ve tried this:

document.getElementById('fileElementId').value

But this only returns one file name when I select multiple files.
Using JavaScript is how do I retrieve the number of selected files and their names from a file input element with a multiple attribute?

  • 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-22T17:14:10+00:00Added an answer on May 22, 2026 at 5:14 pm

    In new browsers that support the HTML5 file stuff, your <input> element will have a “files” property. That will give you a “FileList” reference, which has a “.length” property. There’s also an access method called “.item()” on the “FileList” instance, and it takes an integer arg to access individual “File” elements. Those have a “.name” property.

    So:

    var inp = document.getElementById('fileElementId');
    for (var i = 0; i < inp.files.length; ++i) {
      var name = inp.files.item(i).name;
      alert("here is a file name: " + name);
    }
    

    This will of course not work in older IE versions, and I’m not even sure how thorough the Safari and Chrome support is; however, if you’re writing pages with “multiple” set on your file inputs you’re already dancing on the edge 🙂

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

Sidebar

Related Questions

if i have one form that include some input, textarea, select, and multiple file.
I have created a JAR file in this way jar cf jar-file input-files .
I have this use case of an xml file with input like Input: <abc
I have two exe(A and B) files and a input(C) file. Firstly, The A
I have the following markup: <select multiple=multiple id=targetFilesList style=width:200px;height:110px;> </select> <input type=button value=Get id=btnGet
I have a script where users can upload multiple files (max. 8). The HTML
I have a batch file which runs multiple sql files and passes parameters to
I have a file input element that needs to be cloned after the user
I have an input file that I want to sort based on timestamp which
I have a list of file input boxes and I want to know if

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.