👉 firebase.storage is not a function
☔ Cause of error
👉 Try using the relative route.
🧙 Solution
👉 Please refer to the code below
<script src="/__/firebase/7.4.0/firebase-auth.js"></script>
<script src="/__/firebase/7.4.0/firebase-storage.js"></script>
<script src="/__/firebase/7.4.0/firebase-firestore.js"></script>
<script src="/__/firebase/init.js"></script>
<script>
function fileUpload(file){
var metadata = {
'contentType': file.type
};
var storageRef = firebase.storage().ref();
var uploadTask = storageRef.child('images/test').put(file, metadata);
uploadTask.on('state_changed', function(snapshot) {}, function(error) {
alert("error!");
}, function() {
uploadTask.snapshot.ref.getDownloadURL().then(function(downloadURL) {
alert('success!');
});
});
}
</script>
Did my writing help you?
Please press the Thumb Up button
If you have any questions, please leave them in the comments