0

I've saved images in an directory outside react project then I tried to render them in a react component but it fails.

rendering

Project structure

// path: /frontend/src/components/Product.js
<img
    src='/uploads/image-1608360523657'
    style={{ width: 253, height: 208 }}
/>
flaxel
  • 4,173
  • 4
  • 17
  • 30
A.Usama
  • 157
  • 2
  • 8

2 Answers2

0

Import image like component :

import fallImg from "../uploads/image-1608360523657.jpg";
b3hr4d
  • 4,012
  • 1
  • 11
  • 24
0

Import image first, then use specified name as a reference to the image

import someImageName from '/path/to/your/image/here'

<img
    src={someImageName}
    style={{ width: 253, height: 208 }}
/>
Mile Mijatović
  • 2,948
  • 2
  • 22
  • 41
  • I can't do this because the uploads folder located outside react project folder because it's a static folder to the backend. – A.Usama Dec 19 '20 at 09:11