vue Image Upload Component

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.

Read Also:  vuejs Simple calculator web Application

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 :

Read Also:  Pure CSS custom checkboxes

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.

About Pakainfo

I am Jaydeep Gondaliya, a software engineer, the founder and the person running Pakainfo. I'm a full-stack developer, entrepreneur and owner of Pakainfo.com. I live in India and I love to write tutorials and tips that can help to other artisan, a Passionate Blogger, who love to share the informative content on PHP, Javascript, JQuery, Laravel, Codeigniter, VueJS, AngularJS and Bootstrap from the early stage.

View all posts by Pakainfo →

Leave a Reply

Your email address will not be published. Required fields are marked *