-3

i have a file input field . In that user can choose multiple files for uploading. For that purpose i want to alert and check values which is retrieving correctly .

And i using Form-data to get values . is it possible to alert Form-data values

Thanks in advance

5
  • 1
    what you have try so far? Commented Jun 22, 2015 at 11:13
  • my aim is to upload multiple files at one request . i can able to upload single image in ajax . but while coming to multiple image at once . i have no idea . so i am trying to alert those values . Commented Jun 22, 2015 at 11:14
  • i used this jsfiddle.net/paulftw/umcFW/183. but no idea . its not working Commented Jun 22, 2015 at 11:16
  • visit <stackoverflow.com/questions/27500237/…>? Finally problem solved. Commented Jun 22, 2015 at 11:43
  • Please add code snippets showing what you have tried before. If you found a solution, you can answer your own question and show the solution there or take the question down. Commented Jun 22, 2015 at 13:17

1 Answer 1

0

Yes, you can get all selected files via the files attribute.

var x = document.getElementById("myFile"); 
var txt = ""; 
if ('files' in x) {
    if (x.files.length == 0) {
        txt = "Select one or more files.";
    } else {
        for (var i = 0; i < x.files.length; i++) {
            txt += "<br><strong>" + (i+1) + ". file</strong><br>";
            var file = x.files[i];
            if ('name' in file) {
                txt += "name: " + file.name + "<br>";
            }
            if ('size' in file) {
                txt += "size: " + file.size + " bytes <br>";
            }
        }
    } 
}
alert(txt);

See here for documentation

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

Comments

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.