1

我之前发布了一个类似的问题,但没有得到任何合适的解决方案。

我已经简化了要求:

  1. 用户可以选择多个文件
  2. 从选定的文件中,将每个文件放在单独的表格中
  3. 分别提交每份表格

我正在努力实现第二步。任何帮助都会很棒。欢迎所有想法。

4

1 回答 1

0

有些东西在排队...

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)
}

使用引用的组件的一些示例:

Using_files_from_web_applications(MDN)

DOM/文件阅读器(MDN)

于 2012-06-14T15:19:20.477 回答