-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathscript.js
More file actions
75 lines (54 loc) · 1.73 KB
/
script.js
File metadata and controls
75 lines (54 loc) · 1.73 KB
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
function changeProductImage() {
alert("ok");
var image = document.getElementById("imageuploader");
image.onchange = function () {
var file_count = image.files.length;
if (file_count <= 1) {
alert(file_count);
for (var x = 0; x < file_count; x++) {
var file = this.files[x];
var url = window.URL.createObjectURL(file);
document.getElementById("i" + x).src = url;
}
} else {
alert("please select an image");
}
}
}
function addProduct() {
// alert("ok");
var category = document.getElementById("category");
// alert (category);
var tag = document.getElementById("tag");
var image = document.getElementById("imageuploader");
var txt = document.getElementById("text");
var f = new FormData();
f.append("ca", category.value);
f.append("t", tag.value);
f.append("txt",txt.value);
f.append("image", image[0]);
var file_count = image.files.length;
for (var x = 0; x < file_count; x++) {
f.append("image" + x, image.files[x]);
}
var r = new XMLHttpRequest();
r.onreadystatechange = function () {
if (r.readyState == 4) {
var t = r.responseText;
alert(t);
if (t == "Product image saved successfully") {
window.location.reload();
} else {
alert(t);
}
}
}
r.open("POST", "addProductProcess.php", true);
r.send(f);
}
var bm;
function showmodel(){
var m = document.getElementById("exampleModal");
bm = new bootstrap.Modal(m);
bm.show();
}