Created
September 4, 2020 09:17
-
-
Save besabellacyrus/d5ef5dc93e72f085ae53d69f2f5c40c7 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
onFileSelected(event) { | |
const cloudName = 'dhs0egcjt' | |
const unsignedUploadPreset = 'ideliveryuploadpreset_1' | |
this.selectedFile = event.target.files[0] | |
const fd = new FormData() | |
fd.append('upload_preset', unsignedUploadPreset) | |
fd.append('tags', 'item_images') | |
fd.append('file', this.selectedFile) | |
this.isUploading = true | |
axios | |
.post(`https://api.cloudinary.com/v1_1/${cloudName}/upload`, fd) | |
.then((res) => { | |
if (res.status === 200) { | |
console.log({ res }) | |
this.itemPhoto = res.data.url | |
} | |
this.isUploading = true | |
}) | |
.catch((e) => { | |
alert('Something went wrong. please try again') | |
this.isUploading = false | |
}) | |
}, |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment