I'm trying to upload an image to the Firebase Storage. When I try it on Mozilla Firefox, it shows me the error:
Uncaught exception: Object
but when I try it on Google Chrome it shows me the following: undefined. Can anyone help?
alert('upload js is working');
function imageUpload(){
const ref = firebase.storage().ref();
const file = $('#avatar').get(0).files[0];
const name = 'user_' + $( "#userid" ).val() + '_' + (+new Date());
const task = ref.child(name).put(file);
task.then((snapshot) => {console.log(snapshot.downloadURL);});
task
.then((snapshot) => {
document.querySelector('#someImageTagID').src = snapshot.downloadURL;
})
.catch((error) => {
// A list of errors can be found at
// https://firebase.google.com/docs/storage/web/handle-errors
switch (error.code) {
case 'storage/unauthorized':
// User doesn't have permission to access the object
break;
case 'storage/canceled':
// User canceled the upload
break;
case 'storage/unknown':
// Unknown error occurred
break;
}
})
}
Aucun commentaire:
Enregistrer un commentaire