zoukankan      html  css  js  c++  java
  • 微信图片上传

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

    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()

    真正的认识自己,才能做好自己,做好自己,才能做好你将会做的每一件事。
  • 相关阅读:
    创建二叉树
    并查集
    opn模块
    【ES6】map、reduce、filter、sort、箭头函数、class继承、yield
    css应用视觉设计
    json解决ajax跨域的原理
    flex盒子布局
    前后台交互ajax请求模块
    react后台项目开发(一)
    高阶函数&&高阶组件(二)
  • 原文地址:https://www.cnblogs.com/encore620/p/5620307.html
Copyright © 2011-2022 走看看