summaryrefslogtreecommitdiff
path: root/iridescence/src
diff options
context:
space:
mode:
Diffstat (limited to 'iridescence/src')
-rw-r--r--iridescence/src/components/admin/ProductEditCard.vue43
1 files changed, 30 insertions, 13 deletions
diff --git a/iridescence/src/components/admin/ProductEditCard.vue b/iridescence/src/components/admin/ProductEditCard.vue
index 8d1eb3d..238c975 100644
--- a/iridescence/src/components/admin/ProductEditCard.vue
+++ b/iridescence/src/components/admin/ProductEditCard.vue
@@ -214,27 +214,44 @@ export default {
this.newProduct.quantity += amount;
}
},
- previewFiles(event) {
+ async previewFiles(event) {
let file = event.target.files[0];
if (!file) {
return;
}
- let reader = new FileReader();
+ const fd = new FormData();
+ fd.append(file.name, file);
- reader.onprogress = e => {
- if (e && e.lengthComputable) {
- this.fileProgress = parseInt((e.loaded / e.total) * 100, 10);
- }
- };
+ const response = await fetch("http://localhost:8000/photos", {
+ method: "POST",
+ body: fd
+ });
+ console.log(response);
+ //let reader = new FileReader();
+
+ //reader.onprogress = e => {
+ // if (e && e.lengthComputable) {
+ // this.fileProgress = parseInt((e.loaded / e.total) * 100, 10);
+ // }
+ //};
+
+ //reader.onloadend = e => {
+ // this.fileProgress = 100;
+ // this.newProduct.imgPath = file.name;
+
+ // let formData = new FormData();
+ // formData.append(file.name, e.target.result);
- reader.onloadend = e => {
- console.log(e.target.result);
- this.fileProgress = 100;
- this.newProduct.imgPath = file.name;
- };
+ // fetch("http://localhost:8000/photos", {
+ // method: "POST",
+ // body: formData
+ // }).then(r => {
+ // console.log(r);
+ // });
+ //};
- reader.readAsDataURL(file);
+ //reader.readAsBinaryString(file);
}
}
};