we will use the good old html input element of type file and hid it then have the react component interact with the html element using useRef
xxxxxxxxxx
const ImageInput = (props: Props) => {
const selectFileRef = useRef<HTMLInputElement>(null);//this will be the html-input instance
return (
<Flex justify="center" align="center" width="100%">
<Flex
justify="center"
align="center"
p="20"
border="1px dashed"
borderColor="gray.400"
width="100%">
<Button
variant="outline"
height="28px"
onClick={() => selectFileRef.current?.click()}>
Upload
</Button>
</Flex>
<input type="file" hidden ref={selectFileRef} />
</Flex>
);
};
when you click the button it should open the file system