欢迎来到吴小小的专栏!

js上传文件

//jquery
        var formdata = new FormData();
        formdata.append("file", e.target.files[0]);
        $.ajax({
            type: 'post',
            dataType: 'json',
            url: 'url'
            data: formdata,
            contentType: false,
            processData: false
        }).success((data) => {

        }).error((data, timeout, err) => {

        })

//axios
        let formData=new FormData();
        formData.append('attachment',file);
        let config = {
            headers: {
                'Content-Type': 'multipart/form-data;charset=UTF-8'
            }
        };

        axios.post(url,formData,config).then(({data})=>{
        });

posted @ 2019-07-25 22:34  吴小小  Views(1705)  Comments(0Edit  收藏  举报