I am having trouble uploading an image to firebase storage. I need to have an input object in the HTML with a type of file. Then I need the image selected for that input to be uploaded to the firebase storage for my project. Is there also a way to store the location of that image in the real-time database so it can be accessed later? How would I do this?
Thank you in advance
to link to the database try this:
var ref= firebase.database().ref("Uploads");
var storage = firebase.storage();
var pathReference = storage.ref('images/stars.jpg');
pathReference.getDownloadURL().then(function(url) {
ref.push().set({
imgurl: url
});
more info here:
https://firebase.google.com/docs/storage/web/download-files
https://firebase.google.com/docs/storage/web/upload-files
after adding it to the storage, you will be able to get the url using getDownloadUrl() and then add it in the db:
Uploads
pushid
imgurl: url