鍍金池/ 問答/iOS  HTML/ 小程序替換頭像 wx.uploadFile在pc上測(cè)試和手機(jī)調(diào)試狀態(tài)都可以,就是

小程序替換頭像 wx.uploadFile在pc上測(cè)試和手機(jī)調(diào)試狀態(tài)都可以,就是在手機(jī)上不行,希望幫助下

微信:
467015242

changeAvatar:function (){
        var that=this;
        wx.chooseImage({
            count: 1, // 默認(rèn)9
            sizeType: ['original', 'compressed'], // 可以指定是原圖還是壓縮圖,默認(rèn)二者都有
            sourceType: ['album', 'camera'], // 可以指定來(lái)源是相冊(cè)還是相機(jī),默認(rèn)二者都有
        
            success: function (res) {
                // console.log(avatar,'avatar')
                // 返回選定照片的本地文件路徑列表,tempFilePath可以作為img標(biāo)簽的src屬性顯示圖片
                var avatarSrc = res.tempFilePaths
                console.log(avatarSrc,'avatarSrc')
                wx.uploadFile({
                    url: 'https://product.fishqc.com/User/Profile/upImg',
                    filePath: res.tempFilePaths[0],
                    name: encodeURI('file'),
                    formData: { 'avatar': encodeURI(avatarSrc) }, // HTTP 請(qǐng)求中其他額外的 form data
                    header: {
                        'content-type': 'multipart/form-data', // 默認(rèn)值
                        'skey': wx.getStorageSync('getstoreskey')
                    },
                    success: function (info) {
                        // that.getuserheadImgstatus()
                        // that.getuserInfo()
                        that.setData({
                            'UserInfodata.image': res.tempFilePaths[0],
                            'Headimg': res.tempFilePaths[0]
                        });
                        wx.setStorageSync('image', res.tempFilePaths[0]);
                        wx.setStorageSync('Headimg', res.tempFilePaths[0]);
                    }
                })
            }
        })
    }
回答
編輯回答
你的瞳

https://product.fishqc.com/Us...

沒有配置上傳的安全域

clipboard.png

另外開發(fā)工具關(guān)閉

clipboard.png
你會(huì)發(fā)現(xiàn)一樣不行

2017年6月26日 16:30