0

在这个文档中说,在 Javascript 中,我们不能在“输入”元素中编辑 FileList,因为它是只读的。那么,将我可以编辑的其他一些 javascript FileList 发送到服务器的替代方法是什么?

4

1 回答 1

0

这是一个 HTML 测试页:

<!DOCTYPE html>
<html>
<head>
  <meta charset="UTF-8" />
  <title>test-page</title>
 <script type="text/javascript">
//<!--

var fileobj, file;
function init()
{ fileobj=document.getElementById('filepick');
  fileobj.focus();
  fileobj.click(); //SHOULD auto-trigger the file-select popup, but doesn't
  return;
}

function filed()
{ file = fileobj.files;
  //At this point we should have an array of "item" objects,
  // containing all the files in the directory.
  //You can write code to pluck whatever you want from the array,
  // and then send that list to the server.
  return;
}

 // -->
 </script>
</head>
<body onload="init();">
<input id="filepick" type="file" multiple="multiple" onchange="filed();" /><br />
User: please click button and select all files in the relevant directory.  Thanks!
</body>
</html> 
于 2014-11-19T16:42:40.103 回答