// image file creation from canvas data const image = canvas.toDataURL("image/png").replace("image/png", "image/octet-stream"); // trigger local save prompt automatically window.location.href=image;
Use input
element with type="file"
to trigger a file upload.
<input type="file" className={'text-sm ml-2'} name="myImage" // Event handler to capture file selection and update the state onChange={(e) => { console.log("e.target.files[0]", e.target.files[0]); setLoadedImage(loadedImg); // Update the state with the selected file }} />