Hey, does anyone have any experience doing multipl...
# javascript
m
Hey, does anyone have any experience doing multiple file upload with a styledInput in kotlin? Right now, I have my code like this:
Copy code
class FileUploadComponent : RComponent<FileUploadProps, RState>() {
    override fun RBuilder.render() {
        styledInput(InputType.file, name = "fileUpload", formEncType = InputFormEncType.multipartFormData) {
            css {
                display = Display.none
            }
            attrs {
                id = "FileUploadInput"
                onInputFunction = {
                    event -> println("onInputFunction :: $event")
                    val input = document.getElementById("FileUploadInput") as HTMLInputElement
                    println("VALUE -> ${input.value}")
                }
            }
        }
        styledButton {
            +"Upload Files"
            attrs {
                name = "UploadFileButton"
                onClickFunction = {
                    val field = document.getElementById("FileUploadInput") as HTMLInputElement
                    field.click()
                }
            }
        }
    }
}
But that only does one file at a time, and not multiple files. I know if HTML you would just add something like
<input id='file-input' type='file' multiple/>
and it would work, but I can't figure out how to add the multiple attribute to this input... Any help would be greatly appreciated.
j
you can probably do something like this.attributes.add("multiple") or something like this.attributes["multiple"] = "multiple" should work as well
m
I figured it out, it's jsut a tag of
multiple = true
in the
attrs
section
thanks though
j
awesome!