Last active
February 8, 2023 12:31
-
-
Save faveoled/62713362076826b2fdf91a1da0bedfe8 to your computer and use it in GitHub Desktop.
J2CL Read File contents
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // add to html: | |
| // <input type="file" id="file-selector" multiple> | |
| HTMLInputElement fileSelector = (HTMLInputElement) DomGlobal.document.getElementById("file-selector"); | |
| fileSelector.addEventListener("change", event -> { | |
| FileList files = ((HTMLInputElement) (event.target)).files; | |
| for (int i = 0; i < files.length; i++) { | |
| File file = files.item(i); | |
| file.arrayBuffer() | |
| .then( | |
| success -> { | |
| DomGlobal.alert("success: \n" + success.byteLength); | |
| return null; | |
| }, | |
| error -> { | |
| DomGlobal.alert("error: " + error); | |
| return null; | |
| } | |
| ); | |
| DomGlobal.alert(file.name); | |
| } | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment