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
  • 3,429
  • 4
  • 13
  • 26
A.Usama
  • 25
  • 5

2 Answers2

0

Import image like component :

import fallImg from "../uploads/image-1608360523657.jpg";
b3hr4d
  • 2,970
  • 8
  • 20
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,535
  • 1
  • 22
  • 36
  • 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