Created
November 26, 2019 19:19
-
-
Save Timtech4u/fb77518e4dc01cdfe39778541add73d2 to your computer and use it in GitHub Desktop.
Vue - Cloudinary Upload Widget : https://cloudinary.com/documentation/upload_widget
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
| <template> | |
| <button id="upload_widget" class="cloudinary-button">Update Logo</button> | |
| </template> | |
| <script> | |
| methoods : { | |
| uploadWidget() { | |
| let myWidget = cloudinary.createUploadWidget( | |
| { | |
| cloudName: "mercurie", | |
| apiKey: "XYZ", | |
| uploadPreset: "XYZ", | |
| multiple: false, | |
| cropping: true, | |
| defaultSource: "local", | |
| folder: "mercuriemartlogos", | |
| public_id: "<FILENAME>" | |
| }, | |
| (error, result) => { | |
| if (!error && result && result.event === "success") { | |
| console.log("Done! Here is the image info: ", result.info); | |
| }); | |
| } else { | |
| console.log(error); | |
| } | |
| } | |
| ); | |
| document.getElementById("upload_widget").addEventListener( | |
| "click", | |
| function() { | |
| myWidget.open(); | |
| }, | |
| false | |
| ); | |
| } | |
| }, | |
| }, | |
| mounted () { | |
| this.uploadWidget() | |
| } | |
| </script> |
Author
Couldn't get this to work.
<template> <button id="upload_widget" class="cloudinary-button">Update Logo</button> </template> <script> export default { methods: { uploadWidget() { let myWidget = cloudinary.createUploadWidget( { cloudName: "mercurie", apiKey: "XYZ", uploadPreset: "XYZ", multiple: false, cropping: true, defaultSource: "local", folder: "mercuriemartlogos", public_id: "<FILENAME>" }, (error, result) => { if (!error && result && result.event === "success") { console.log("Done! Here is the image info: ", result.info); } else { console.log(error); } } ); document.getElementById("upload_widget").addEventListener( "click", function() { myWidget.open(); }, false ); }, }, mounted () { this.uploadWidget() } } </script>
No problem, I'll try to fix it in. Thanks
Thanks Tim. Wonder what's wrong.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Couldn't get this to work.