jquery Ajax 实现图片上传的功能。

$('#image').on('change', function () {
        var url = "";
        var form = new FormData();
        form.append("file", this.files[0]);
        var settings = {
            "url": url,
            "method": "POST",
            "timeout": 0,
            "headers": {
                deviceType:"5",
                deviceId:md5("navigator.userAgent")
            },
            "processData": false,
            "mimeType": "multipart/form-data",
            "contentType": false,
            "data": form
        };
        $.ajax(settings).done(function (response) {
            console.log(response);
        });
    })

  

posted @ 2019-01-11 09:12  流年瓦解我们的记忆  阅读(596)  评论(0编辑  收藏  举报