I was trying the following code in react, and I am getting the following error in Chrome (updated) and Opera browsers. Any idea how to fix it ?
return (
<Button
component="label"
role={undefined}
variant="contained"
tabIndex={-1}
startIcon={<CloudUploadIcon />}
>
Upload file
<VisuallyHiddenInput type="file" onChange={handleFileUpload} />
</Button>
);
const handleFileUpload = (e) => {
if (!e.target.files) {
return;
}
const file = e.target.files[0];
const filename = file.name;
window.open(
import.meta.env.VITE_DAEJAVIEWER + `?image="${filename}"`, // a simply url
"_blank"
);
};
const VisuallyHiddenInput = styled("input")({
clip: "rect(0 0 0 0)",
clipPath: "inset(50%)",
height: 1,
overflow: "hidden",
position: "absolute",
bottom: 0,
left: 0,
whiteSpace: "nowrap",
width: 1,
})
Also note that Firefox is working, but not in Chrome, Opera, Edge
thanks


it is due to you are refereing to the current file.you need to convert it into another blob so that that it will refer to another file than the active one.here you can try this.