我编写了用于上传到Firebase存储目录的代码。我必须使用Javascript调整所选图像的大小。图片应为 65x65 尺寸。
这是我的代码:
firebase.auth().onAuthStateChanged(function(user) {
if (user) {
//Handling Contact Form
var uploader_profilfotograf = document.getElementById('uploader_profilfotograf');
var fileButton_profilfotograf = document.getElementById('fileButton_profilfotograf');
fileButton_profilfotograf.addEventListener('change', function(e){
var file = e.target.files[0];
var storageRef = firebase.storage().ref('profile_images/'+user.uid);
var task = storageRef.put(file);
task.on('state_changed', function progress(snapshot) {
var percentage = (snapshot.bytesTransferred/snapshot.totalBytes)*100;
uploader_profilfotograf.value = percentage;
}, function error(err) {
},function complete() {
});
});
}
});