5***@qq.com
5***@qq.com
  • 发布:2023-09-07 20:50
  • 更新:2023-09-07 20:50
  • 阅读:269

指定文件夹的上传云存储的这段代码,在H5端没有任何问题,但是在APP-PLUS端却上传不了。

分类:uni-app


                uni.hideLoading()  
                uni.chooseImage({  
                    count: 2,  
                    crop: {  
                        quality: 100,  
                        width: 420,  
                        height: 560  
                    },  
                    sourceType: ['album'],  
                    success: async res => {  

                        uni.showLoading({  
                            title: "上传中请稍后",  
                            mask: true  
                        })  
                        for (let item of res.tempFiles) {  
                            if (item.size > 1 * 1024 * 1024) {  
                                // uni.$u.toast(图片大小不能超过1M)  
                                uni.showToast({  
                                    title: "图片大小不能超过1M!"  
                                })  
                                return  
                            }  
                            let suffix = item.name.substring(item.name.lastIndexOf("."));  
                            let randomName = Date.now()  + "" +  String(Math.random()).substr(3, 6)  + suffix  

                            let res = await uniCloud.uploadFile({  
                                cloudPathAsRealPath: true,  
                                filePath: item.path,  
                                cloudPath: "mainEquipment/" +  randomName  
                            })  
                            this.editorCtx.insertImage({  
                                src: res.fileID  
                            })  
                        }  
                        uni.hideLoading()  
                    }  
                })  
            },```  

指定文件夹的上传云存储的这段代码,在H5端没有任何问题,但是在APP端却上传不了。  
2023-09-07 20:50 负责人:无 分享
已邀请:

要回复问题请先登录注册