Can someone show me an example how to do file uplo...
# webassembly
s
Can someone show me an example how to do file uploads in Compose for Web WASM? I learned in #compose-web that I will need js-interop, but I have no experience with web development. I want users to select (or drag and drop) a file on disk and get that file content as a ByteArray.
👀 1
✅ 1
r
You would need to place an html
<input type='file'>
element somewhere on the page. I'm not sure how to do this in canvas-based compose.
Perhaps by some direct DOM manipulation, you could create a floating div with an input element.
Having the element on the page you can access its
files
property and then use a function like this to get base64-encoded file content: https://github.com/rjaros/kilua/blob/main/kilua/src/commonMain/kotlin/dev/kilua/utils/File.kt#L34-L43