I need to upload the image using vue js.
My html code to insert picture is
<input type="file" id="wizard-picture">
My vue js code is as..
<script>
submitBox = new Vue({
el: "#submitBox",
data: {
username: '',
picture: '',
},
methods: {
handelSubmit: function(e) {
var vm = this;
data = {};
data['username'] = this.username;
data['picture'] = this.picture;
$.ajax({
url: 'http://127.0.0.1:8000/api/add/post/',
data: data,
type: "POST",
dataType: 'json',
success: function(e) {
if (e.status)
{
alert("Registration Success")
window.location.href = "https://localhost/n2s/registersuccess.html";
}
else {
vm.response = e;
alert("Registration Failed")
}
}
});
return false;
}
},
});
</script>
What can I do to implement the same. This is the first time I am doing a work. I am stuck on the same. Can anybody Please help me to obtain the result?
e.target.files[0]to your jquerydata:data:datawithdata:e.target.files[0]