phpreactjslaravelsftplaravel-7

Uploading an Image from the backend to a react front end folder


There are three major components that the website is composed of:

  1. ADMIN Backend/Frontend: PHP Laravel Framework

  2. Backend: PHP Laravel Framework

  3. Frontend: React Frontend

I've been assigned to add functionality to the ADMIN Console (ADMIN Backend/Frontend) by giving the ADMIN user the ability to change the static images on the website. Currently, these static images are stored in a folder on the react frontend, and I was advised to keep the static images on the react frontend so react can reference them locally. Therefore, I need to figure out a way to upload these images to the same location where react is referencing them which is on the live dev server. However, I noticed that these images have a hash tag of some sorts attached to the original images: (orignal image name).(hashtag).jpg. The problem is that I don't know what the auto-generated hashtag is attached to each image, because it changes every time the website's react code is recompiled. The only approach that I can think of requires the following steps:

Step 1: Upload the image that I want to have shown (replacing the old image with this image)

Step 2: Get the html code of the page that will display this image. Then parse the html code to get the old image's path which includes the hashtag attached to it's name.

Step 3: Upload the new image via SFTP to the dev server using the path from step 2 to replace the old image.

Does anyone have a better way of doing this? Is this a bad approach?

Feedback is greatly appreciated.


Solution

  • Thank you everyone for your feedback, I got my images uploaded referencing a public folder.