added upload button

This commit is contained in:
2021-08-15 17:27:06 +02:00
parent 4655f2f8c1
commit 4d85a419cc
2 changed files with 30 additions and 0 deletions

View File

@@ -0,0 +1,26 @@
import React from "react"
import { useRef } from "react"
interface Props {
onUpload?: (files: FileList)=>void
}
const FileUploadButton: React.FC<Props> = (props) => {
const inputRef = useRef<HTMLInputElement>(null)
return (
<>
<button onClick={()=>inputRef.current?.click()} >
Upload files
</button>
<input type="file" multiple style={{display:"none"}} ref={inputRef} onInput={()=>{
if (inputRef.current && inputRef.current.files){
props.onUpload?.(inputRef.current.files)
}
}}/>
</>
)
}
export default FileUploadButton