文件的上传网页通过ajax

    //设置文件
    let formData = new FormData();
    formData.append('file',event.target.files[0]);
    let attorneyImg = {
        data:  formData
    }
    
    

        $.ajax({
            url: "http://00000.work:19099/imgifile" ,//请求ip加上请求地址
            type: "POST",

            data: attorneyImg.data,
            processData: false,
            contentType: false,

            headers: {
                "Authorization":localStorage.getItem('key'),  //设置请求key
            },

            success: function (data) {
                console.log(data);

            },
            error: function (error) {
                console.log(error);
            }
        });


});

你可能感兴趣的:(ajax,javascript,ecmascript)