0

I successfully uploaded an image with imagepicker and multer to my folder "uploads/".

I also send the filename back to the client:

res.send({uploadedImage: req.file.path});
// Result:
Object {
  "uploadedImage": "uploads\\photo_1619350900261_b1099740-f86c-4809-ae62-0ad973a499c0.jpg",
}

So how can I now read the file or the image? I can put this in a state but there is no url in this image object upload.

localdata01
  • 587
  • 7
  • 17

1 Answers1

1

To Display the image from response

Use it like this

BaseURL = The URL at which you send post requests (i.e, your Backend Server)

Result.uploadedImage = This you get from the response

So the final uri would be

uri = BaseURL + Result.uploadedImage

It will look Something like this localhost:3000/uploads\\photo_1619350900261_b1099740-f86c-4809-ae62-0ad973a499c0.jpg or 127.0.0.1:3000/uploads\\photo_1619350900261_b1099740-f86c-4809-ae62-0ad973a499c0.jpg

But if you are working on your phone then you might have to replace your BaseURL with your IPv4 address.. This address you can get it from CMD

1.) Open CMD

2.) type ipconfig

3.) Scroll down and look for IPv4 Address..It will look something like this 192.168.100.74

4.) Now uri_to_display = IPv4 Address + : + PORT + Result.uploadedImage

Kartikey
  • 4,516
  • 4
  • 15
  • 40