I am working on an application in which I have to upload multiple images. I am using redux-saga
and Nexjs
. Right now it is uploading a single image but selecting multiple images.
My Code:
const inputFile = React.useRef(null);
const onChangeFile = event => {
event.stopPropagation();
event.preventDefault();
var image = event.target.files[0];
if (image) {
var temp = URL.createObjectURL(image);
onImageSelect && onImageSelect(temp);
set_disabled(true);
dispatch(
post.uploadImage({
fileObject: image,
callback: source_url => {
imageHandler(source_url);
set_disabled(false);
event.target.value = null;
onImageUploaded && onImageUploaded();
},
})
);
}
};
and JSX:
<>
<input
accept='image/*'
type='file'
ref={inputFile}
style={{ display: 'none' }}
onChange={onChangeFile}
multiple
/>
<Box clone color='#666'>
<IconButton
size='small'
onClick={() => {
inputFile.current.click();
}}
>
<WallpaperOutlinedIcon />
</IconButton>
</Box>
</>
Which changes do I need to add to upload multiple images I ama bit confuse. Thanks