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?
Asked
Active
Viewed 606 times
0
-
You are up against a problem where JavaScript's security model prevents easy access to the file system. The browser, being an executable application, has such access, but JavaScript code isn't the browser's executable code --and, actually, the access to the file system is done through HTML code, not JavaScript: ``. Worse, in my experimentation it appears that there is no way to automatically trigger the popup window where you select a file (in theory the object's `click()` function should do that). Still, IF you can trust the user, then a kind of Answer exists (below). – vernonner3voltazim Nov 19 '14 at 16:42
-
Thanks all, but I found the solution in other [topic](http://stackoverflow.com/a/12503471/2650905). – Paul Nov 20 '14 at 14:13
1 Answers
0
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>

vernonner3voltazim
- 780
- 6
- 5