summaryrefslogtreecommitdiff
path: root/iridescence
diff options
context:
space:
mode:
authorAdam T. Carpenter <atc@53hor.net>2020-11-04 08:59:41 -0500
committerAdam T. Carpenter <atc@53hor.net>2020-11-04 08:59:41 -0500
commit76ad709e0afed734c4331ddb8de91745a541a67d (patch)
treebe7b3d20387506ed23fa9c4f4f386ef3bbb1ae86 /iridescence
parentdcc96d0b349583e5d6a0f25ae1f7a3ffa3769788 (diff)
downloadtheglassyladies-76ad709e0afed734c4331ddb8de91745a541a67d.tar.xz
theglassyladies-76ad709e0afed734c4331ddb8de91745a541a67d.zip
basic photo upload working completely
Diffstat (limited to 'iridescence')
-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);
}
}
};