Jquery无刷新上传单个文件

function ajax_photo(photo_type){
        $(document).on('change','#sitephoto',function(){
            var formData = new FormData();
            formData.append("myfile", document.getElementById('sitephoto').files[0]);
            formData.append('photo_type',photo_type);
            $.ajax({
                url: "/sitef/sitebase/savephoto",
                type: "post",
                dataType:'json',
                data: formData,
                contentType: false,
                processData:false,
                async:false,
                success: function (msg) {
                    window.location.href = '/sitef/sitebase/editphoto';
                },
            });
        })
    }

posted @ 2018-08-15 17:10  王浩栋  阅读(282)  评论(0编辑  收藏  举报