1***@qq.com
1***@qq.com
  • 发布:2022-12-02 10:44
  • 更新:2022-12-02 10:44
  • 阅读:227

支付宝小程序uni.uploadFile 上传图片提示 uploadFile:fail 无效参数

分类:uni-app
<template>  
    <view style="margin-top: 10%;">  
        <button type="primary" @click="upload()">测试上传</button>  
    </view>  
</template>  

<script>  
    const app = getApp()  
    export default {  
        data() {  
            return {  

            };  
        },  
        onLoad(options) {  

        },  
        methods: {  
            upload() {  
                let that = this;  
                uni.chooseImage({  
                    count: 1, // 拍照或相册选择  
                    sizeType: ['compressed'],  
                    sourceType: ['album', 'camera'],  
                    success: function (res) {  
                        let header = {}  
                        if (uni.getStorageSync("tokenName")) {  
                            header[uni.getStorageSync("tokenName")] = uni.getStorageSync("token")  
                        }  
                        console.log(app.globalData.IP + "user/alipay/ocr")  
                        uni.uploadFile({  
                            url: app.globalData.IP + "user/alipay/ocr",  
                            filePath: res.tempFiles[0],  
                            fileType: 'image',  
                            formData: {  
                                type: "face"  
                            },  
                            header: header,  
                            success: (res) => {  
                                console.log(res)  
                            },  
                            fail:(err) => {  
                                console.log(err)  
                            }  
                        });  
                    }  
                });  
            }  
        }  
    };  
</script>  
<style lang="scss"></style>  
2022-12-02 10:44 负责人:无 分享
已邀请:

该问题目前已经被锁定, 无法添加新回复