• Status: Solved
  • Priority: High
  • Security: Public
  • Views: 71
  • Last Modified:

Extract Input Type File info with jQuery

Hi Experts,

I have an array of <input type="file" name="file[]" id="file[]">, and I am wondering how can I extract the name and size of the selected files?

So far I have the below, and for the first file, file[0], I need to get
name = "test - Copy.txt"
size = 16

As you will you will see from my output
Files.JPG
File-0.JPG
0
APD Toronto
Asked:
APD Toronto
  • 2
1 Solution
 
Dorababu MSenior Software EngineerCommented:
Is it a single control, can you show me the design of your control how it is place on the form?
0
 
Dorababu MSenior Software EngineerCommented:
You can give a try like this

$("input[name=file1]").change(function() {
    var size = [];
    for (var i = 0; i < $(this).get(0).files.length; ++i) {
        size.push($(this).get(0).files[i].size);
    }
});

Open in new window

0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now