File upload to v86 #676
Replies: 2 comments 6 replies
-
So here's my final solution. It a little janky but it works.
|
Beta Was this translation helpful? Give feedback.
2 replies
-
There were some bugs in your code. I just patched it up.
```js
document.getElementById("upload_files").onchange = function(e) {
var files = e.target.files;
for(var i=0;i<files.length;i++) {
var reader = new FileReader();
reader.onload = function(file) {
return function(e) {
var data = (new TextEncoder('UTF-8')).encode(e.target.result);
emulator.create_file("/user/"+file.name, data);
console.log("uploaded "+file.name);
}
}(files[i]);
reader.readAsText(files[i]);
}
}
```
Use showDirectoryPicker if you're using Chromium; that'll let you share entire directories with v86.
Or [webkitdirectory](https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/webkitdirectory). It’s on everything except internet explorer.
|
Beta Was this translation helpful? Give feedback.
4 replies
Answer selected by
Darin755
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
How do you code a file upload to v86? I have the following code so far:
I need to figure out how to get the data from file.
Please help . . .
UPDATE 1
So I now have the following code:
I don't know how to get the file name and the file itself seems to be garbled.
Update 2
Here's my code:
It works for file upload now I need to figureout a way to get the filename
Beta Was this translation helpful? Give feedback.
All reactions