How to send javascript editable FileList to server?

637 views Asked by At

In this documentaion says that in Javascript we cann't edit FileList inside 'input' element, because it is readonly. So what are the alternatives to send some other javascript FileList, that i can edit, to server?

1

There are 1 answers

0
vernonner3voltazim On

This is an HTML test-page:

<!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>