微信图片上传

我只想说被坑的完全无语了,感谢万能的网友

function chooseImage() {
            wx.chooseImage({
                count: 1, // 默认9
                sizeType: ['compressed'], // 可以指定是原图还是压缩图,默认二者都有
                success: function (res) {
                    images.localId = res.localIds;
                    uploadImage(res.localIds.toString());
                    jQuery(function () {
                        $("#upImages").append('<li class="weui_uploader_file"><img src="' + res.localIds + '" style="79px; height:79px;"/></li>');
                    });
                }
            });
        }

        function uploadImage(resId) {
            wx.uploadImage({
                localId: resId,
                success: function (res) {
                    downloadImage(res.serverId);
                },
                fail: function (res) {
                    alert(JSON.stringify(res));
                }
            });
        }
        function downloadImage(serverId) {
            $.ajax({
                url: 'handlers/StudentHandlers.ashx?action=downImage',
                data: {
                    mediaId: serverId
                },
                success: function (result) {
                    alert(result);
                }
            });
        }

  在uploadimage的时候一直没有反应,就是不上传图片,感谢万能的网友们

res.localIds.toString()
res.localIds.toString()
res.localIds.toString() 重要的事情说三遍,这里要加上toString()

真正的认识自己,才能做好自己,做好自己,才能做好你将会做的每一件事。
原文地址:https://www.cnblogs.com/encore620/p/5620307.html