How upload images or pdf file in my droplet storage?

December 28, 2018 1.4k views
DigitalOcean Development Ubuntu 16.04

I have a React app + express hosted in a Droplet.
I want to allow my users to upload some pictures, save this pictures in my droplet and get a sort of reference to be able to show this picture where I want.

For example a user wants to write a news article, they upload a picture to show in the article.. and then once the user upload the picture, from the JAVASCRIPT point of view.., how can I save this picture from my react front end to digital ocean? and then how can I get back a reference of that image to show it in the news article?

Thanks

1 Answer
jarland MOD December 28, 2018
Accepted Answer

Hey friend,

Great question. I found a tutorial that may be helpful:

https://codeburst.io/react-image-upload-with-kittens-cc96430eaece

For your purposes, it may help matters to consider this not specific to DigitalOcean. For example, this question:

"how can I save this picture from my react front end to digital ocean"

Would be better phrased as:

"how can I save this picture from my react front end to a Linux file system"

This extracts specific detail and replaces it with the generic one, because while the problem may have been solved in the generic fashion, there may be less information available about it that specifies DigitalOcean (which, in this case, is an interchangeable variable of no consequence).

Hope that helps :)

Jarland

  • Thank you jarland! This is a great guide!

    But here it explains how to save the images in a specific third part host called Cloudinary but what if I want to save the images in my droplet? in the machine where I run my website? Do I need a storage for that?

    How could I upload and then save an image in my droplet using react AND THEN receive a reference of where the image has been saved?

    Thank you

Have another answer? Share your knowledge.