0

I have a react component that consists of a table that I'd like to export as a Jpeg. I have found libraries such as react-component-export-image, but this exports the image and then asks the user where they'd like to save the image. I'd like to save the image automatically to a folder in the project, without having the user have to go through the File Explorer. Basically, they just click a button on the page and then the image is saved in a folder within the project. Can anyone point me in a direction on how to do this? Thanks in advance!

  • 1
    You can't just save things to a user's computer without them saying that's OK. It's a massive security issue. – Andy Aug 29 '21 at 23:23
  • 1
    First of all react is a client side app. That means it runs on a browser. Imagine you fix a folder to save your file, whats the guarantee that such folder exists on every user machines? More over you can't directly access user's folders directly. Only option is to give the user to choose one. – Sanish Joseph Aug 29 '21 at 23:25
  • @SanishJoseph Is it possible to save the image in local storage? – Michael Fourie Aug 29 '21 at 23:35
  • You can. Convert the image to base64 string and you are good to go. – Sanish Joseph Aug 29 '21 at 23:49

1 Answers1

0

You cannot save automatically to the user's PC without asking due to security reasons. None of the browsers supports this.

Pakira
  • 1,951
  • 3
  • 25
  • 54