Hello all, I am trying to add a file in the form, but I'm new in Vue.js and I'm having troubles with that. Can anyone help please?
<div class="form-group ">
{!! Form::label('category','Category') !!}
{!! Form::text('cat',null,['class'=>'form-control','v-model'=>'cat']) !!}
</div>
<div class="form-group ">
{!! Form::label('image','Photo') !!}
{!! Form::file('image',null,['class'=>'form-control','v-model'=>'image','v-model'=>'file','ref'=>'file','v-on:change'=>'handleFileUpload()') !!}
</div>
data:{
videos:[],
cat : null,
image: '',}
methods:{
handleFileUpload(){
this.file = this.$refs.file.files[0];
},
saveVideo(){
var formData = new FormData();
formData.append('image', this.file);
formData.append('cat, this.category);
$.ajax({
url:'/settings/video/store',
type:'post',
processData: false,
contentType: false,
data: formData,
success:function(){
}
})
},
Image is sent as empty string