Uploading files with VueJS, axios and Laravel

后端 未结 2 1920
余生分开走
余生分开走 2020-12-19 17:12

Hello I am building one project. Where user can send up to 5 images and up to 10 songs with the text. But when I send request to the server, where I handle with Laravel, I c

2条回答
  •  误落风尘
    2020-12-19 18:01

    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")
                })
            },
        }
     }

提交回复
热议问题