Uploading files with VueJS, axios and Laravel
Oh yeah! you're missing this part. You need to define this.
axios.defaults.headers.post['Content-Type'] = 'multipart/form-data';
this my solutuion
export default { data (){ return { attachment : { name : null,file: null } } }, methods : { onFileChange(event) { this.attachment.file = event.target.files[0] }, attachmentCreate() { var form = new FormData(); form.append('name',this.attachment.name); form.append('file',this.attachment.file); this.$http.post('attachment',form).then(response=>{ console.log("oke") }) }, } }
<input type="file" class="form-control" @change="onFileChange">