Using Upload

First, please follow the instructions to install and setup Cloudinary module.

Client unsigned upload component with Cloudinary

  1. Create an upload component Upload.vue with the following template code:
    <span>Upload to Cloudinary</span>
      aria-label="upload image button"

We assign to the input element to receive input type file and specify accepted file extensions. Then we attach selectFile method to the change event listener. This function will be triggered whenever user selects a file to upload.

  1. Implement the following code for selectFile.
export default {
  methods: {
    async selectFile(e) {
      const file =[0];

      /* Make sure file exists */
      if (!file) return;

      /* create a reader */
      const readData = (f) =>  new Promise((resolve) => {
          const reader = new FileReader();
          reader.onloadend = () => resolve(reader.result);

      /* Read data */
      const data = await readData(file);

      /* upload the converted data */
      const instance = this.$cloudinary.upload(data, {
        folder: 'upload-examples',
        uploadPreset: 'your-upload-preset',
Edit this page on GitHub Updated at Sun, Jun 18, 2023