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

  • Home
  • SEARCH
  • 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 6095491
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T12:49:05+00:00 2026-05-23T12:49:05+00:00

I am trying to use the multiple upload attribute of HTML5 to upload files.

  • 0

I am trying to use the multiple upload attribute of HTML5 to upload files.
I know it wouldn’t work with IE and fall back to single file upload.
also I found some invalid html tag like min max allows opera to do the same.

I am trying to do the following:
The browse button be capable of selecting multiple files.
But the ajax should send files one by one.
My scenario is something like this:
the user selects 5 files and starts the upload . Now the ajax should firstfile send the first file, then second, and so on.
The server side script does something with the file and returns some data.
now as soon as one file upload is completed it must render that part of the result.
So as the user selects images and starts uploading the results come out as soon as each file is uploaded (and not after all the files are uploaded).

I tried something like this :

 function handleFiles(files)
  { alert(files.length); //properly returns the number of files selected
    for (var i = 0; i < files.length; i++) {
  new FileUpload(files[i])
  }
  }

  function FileUpload(file) {
  var reader = new FileReader();

  var xhr = new XMLHttpRequest();
  this.xhr = xhr;

  xhr.open("POST", "portfolio/add_media");
  reader.onload = function(evt) {
    xhr.sendAsBinary(evt.target.result);
  };
  reader.readAsBinaryString(file);
}

after reading the tutorial at mozilla but I end up with missing params.

. so can some one suggest me a clean solution to this

Some more details :
When I pass a single file ( with no multiple attribute ) my server recieves :

“image”=>[# < ActionDispatch::Http::UploadedFile:0x10d55be8
@tempfile=#< File:C:/Users/Gaurav/AppData/Local/Temp/RackMultipart20110701-1916-2ly4k2-0>,
@headers=”Content-Disposition:
form-data; name=\”picture[image][]\”;
filename=\”Desert.jpg\”\r\nContent-Type:
image/jpeg\r\n”,
@content_type=”image/jpeg”,
@original_filename=”Desert.jpg”>]}}

But when I use multiple attribute and send using xhr I am able to get only one file param. How do I get the rest of the params ? esp the action dispatch thingy

  • 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-23T12:49:06+00:00Added an answer on May 23, 2026 at 12:49 pm

    You are simply sending the file data to the server, without encoding it in any way. For the server to know how to process it you need to encode your data properly (multipart/form-data encoding). Easiest way is using a FormData object: https://developer.mozilla.org/En/Using_XMLHttpRequest#Sending_files_using_a_FormData_object. Only that instead of data.append("CustomField", "This is some extra data") you would write data.append("file1", event.target.result).

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

Sidebar

Related Questions

I'm trying to a upload file (or multiple files) to my servlet, which is
I have been trying to use an ajax-style file upload component (like the dojox
I'm trying to use multiple attributes in my custom tag, e.g.: <mytaglib:mytag firstname=Thadeus lastname=Jones
I'm trying to use the freeware Multiple Find And Replace 1.00 suggested in this
I'm trying to serialize a custom class that needs to use multiple elements of
I'm trying to use jcarousel to build a container with multiple rows, I've tried
I'm trying to use svnmerge.py to merge some files. Under the hood it uses
I'm trying to make a webpage that allows the uploading of multiple files at
I am trying to upload a file or stream of data to our web
I'm trying to use multiple parameters with the useradd command in linux, and I'm

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.