0

Is there any option to save jpeg file sent via React as rawFile? So, frontend uses React-admin, on submitting it sends JSON encoded object of a structure like this:

{
  "id":8,
  "client_photo":{
    "rawFile":{
      "path":"DSC_2024.jpg"
    },
    "src":"blob:http://localhost/some-path",
    "title":"DSC_2024.jpg"
  }
}

I'm trying to save it on a server with PHP-script. The problem is that $_FILES and $_POST variables are empty, so the only source I have is that "src" field of the "client_photo" field received from React. How am I supposed to do that?

Sarun UK
  • 6,210
  • 7
  • 23
  • 48
ArMANIAK
  • 19
  • 6
  • 1
    You need to start by modifying how you are sending this on the client side. `"src":"blob:…` is nothing you can actually access on the server side, only on the client side do you have access to such BLOB URL objects. – CBroe Nov 23 '20 at 14:38
  • Unfortunately, the project uses third-party resources and I can't manage to understand how do I change it in order to reach my goal.. Sad situation.. – ArMANIAK Nov 23 '20 at 14:42

1 Answers1

0

Use filereader to read the file and convert it as per your requirement and save it in DB.

Vijay
  • 228
  • 3
  • 8