vue Image Upload Component

Today, We want to share with you vue Image Upload Component.In this post we will show you Uploading Files With VueJS and Axios, hear for File Upload in Vue.js Using vue-dropzone we will give you demo and example for implement.In this post, we will learn about File Upload Component with Vue.js, Express and TypeScript with an example.

vue Image Upload Component

There are the Following The simple About vue Image Upload Component Full Information With Example and source code.

Also Read This πŸ‘‰   vuejs - How to implement Google New reCaptcha with checkbox

As I will cover this Post with live Working example to develop How to upload file in Vue js 2, so the bootstrap vue file upload for this example is following below.

Vue.js File Upload

Uploading Files With VueJS and Axios

Step 1: HTML Part

<div id="root">
  <div v-if="!picture">
    <h2>Select an picture</h2>
    <input type="file" @change="onFileChange">
  </div>
  <div v-else>
    <img :src="picture" />
    <button @click="removeImage">Delete picture</button>
  </div>
</div>

Step 2: vuejs part

new Vue({
  el: '#root',
  data: {
    picture: ''
  },
  methods: {
    onFileChange(e) {
      var files = e.target.files || e.dataTransfer.files;
      if (!files.length)
        return;
      this.createImage(files[0]);
    },
    createImage(file) {
      var picture = new Image();
      var reader = new FileReader();
      var vm = this;

      reader.onload = (e) => {
        vm.picture = e.target.result;
      };
      reader.readAsDataURL(file);
    },
    removeImage: function (e) {
      this.picture = '';
    }
  }
})

Step 3: CSS part

#root {
  text-align: center;
}
img {
  width: 30%;
  margin: auto;
  display: block;
  margin-bottom: 10px;
}
button {
  
}

Web Programming Tutorials Example with Demo

Read :

Also Read This πŸ‘‰   what is shopify? - Everything You Need to Know About shopify themes, pricing, app in 2022

Summary

You can also read about AngularJS, ASP.NET, VueJs, PHP.

I hope you get an idea about vue Image Upload Component.
I would like to have feedback on my infinityknow.com blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.