Vuejs File Upload using $http post and FormData

Vuejs File Upload using $http post and FormData

Welcome on infinityknow.com – Examples ,The best For Learn web development Tutorials,Demo with Example! Hi Dear Friends here u can know to Vuejs File Upload using $http post and FormData

In this post we will show you Best way to implement Uploading files and JSON data in the same request with Vue JS, hear for How to Simple file upload example using Vuejs with Download .we will give you demo,Source Code and examples for implement Step By Step Good Luck!.

READ :  vuejs Check All Uncheck All checkboxes

index.html

[php]

Select an image


[/php]

style(style.css)

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

}
[/php]

index.js

[php]
new Vue({
el: ‘#app’,
data: {
image: ”
},
methods: {
fileupload(e) {
var files = e.target.files || e.dataTransfer.files;
if (!files.length)
return;
this.createImage(files[0]);
},
createImage(file) {
var image = new Image();
var reader = new FileReader();
var vm = this;

reader.onload = (e) => {
vm.image = e.target.result;
};
reader.readAsDataURL(file);
},
DeleteImages: function (e) {
this.image = ”;
}
}
})
[/php]

Example

I hope you have Got Multipart/form-data File Upload with Vuejs And how it works.I would Like to have FeadBack From My Blog(infinityknow.com) readers.Your Valuable FeadBack,Any Question,or any Comments abaout This Article(infinityknow.com) Are Most Always Welcome.

READ :  Vue js Drag and drop multiple file upload with progress bar

Leave a Comment