1

I've posted a similar question earlier but did not got any fit solution.

I've simplified the Requirement:

  1. Ability for user to select multiple files
  2. From the selected files, place each file in an individual form
  3. Submit each form separately

I'm struggling to achieve 2nd step only. Any help would be great. All ideas welcome.

Community
  • 1
  • 1
user1450322
  • 71
  • 2
  • 5
  • If you we able to split the files from your other question, you would do the same here. Please don't post duplicates :) – Scott Stevens Jun 13 '12 at 21:55
  • Guess you will need to avoid submitting the forms and use ajax, since for security reasons file inputs can't be set by javascript. And for that you will probably use the File API. – Prusse Jun 13 '12 at 22:07
  • @Scott S - objective is to split and hold that file in a form until user submit only that particular form, which I'm unable to do at present. – user1450322 Jun 13 '12 at 22:13
  • @Prusse - Thanks for the Tip, I've have been having a look at FILE API. It would be great if you explain further what is that I can exactly use from FILE API? Cheers – user1450322 Jun 13 '12 at 22:19
  • 1
    possible duplicate of [how to get multiple file input from a single input](http://stackoverflow.com/questions/10990890/how-to-get-multiple-file-input-from-a-single-input) – Esailija Jun 14 '12 at 18:10

1 Answers1

0

Some thing in the lines...

HTML:

<input type="file" multiple onchange="handleFiles(this.files)">

JavaScript:

function handleFiles(files){
  //create/associates a form with each file ("files.length" files)
  // ... do stuff ...
}

function doAllSubmits(){
  // for each form call "doAsubmit"
}

function doASubmit(some_id, callback){
  // instantiate a XmlHttpRequest
  // (or use jquery or any other library you're using)
  // use a POST method
  // (if I remember GET has(may have) query size limitations)
  // populate with the form data
  // plus the respective file data
  // (maybe with readAsDataURL)
}

Some examples as to use the components cited:

Using_files_from_web_applications(MDN)

DOM/FileReader(MDN)

Prusse
  • 4,287
  • 2
  • 24
  • 29