-
Notifications
You must be signed in to change notification settings - Fork 0
/
ppupload.js
53 lines (46 loc) · 1.79 KB
/
ppupload.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
function upload() {
//get your select image
var image=document.getElementById("image").files[0];
//now get your image name
var imageName=image.name;
//firebase storage reference
//it is the path where yyour image will store
var storageRef=firebase.storage().ref('images/'+imageName);
//upload image to selected storage reference
var uploadTask=storageRef.put(image);
uploadTask.on('state_changed',function (snapshot) {
//observe state change events such as progress , pause ,resume
//get task progress by including the number of bytes uploaded and total
//number of bytes
var progress=(snapshot.bytesTransferred/snapshot.totalBytes)*100;
console.log("upload is " + progress +" done");
},function (error) {
//handle error here
console.log(error.message);
if(error){var err = document.getElementById("error");
err.style.display = "block";}
},function () {
//handle successful uploads on complete
uploadTask.snapshot.ref.getDownloadURL().then(function (downlaodURL) {
//get your upload image url here...
var ppurl= downlaodURL;
//
$.ajax({
url: 'updatepp.php',
method: 'post',
data: {ppurl:ppurl},
success:function(response){
var secc = document.getElementById("seccess");
secc.style.display = 'inline-block';
}
});
console.log(downlaodURL);
if (ppurl) {
// variable is undefined or null
var secc = document.getElementById("seccess");
secc.style.display = "block";
location.reload();
}
});
});
}