嘻嘻1004
嘻嘻1004
  • 发布:2021-07-15 15:33
  • 更新:2021-07-15 16:07
  • 阅读:471

uni-app用安卓原生定义的目录上传手机指定文件上传失败

分类:uni-app
复制代码that.uper = uni.uploadFile({  
                                url: server_url + '/interfaceapi/upload/album_upload',  
                                filePath: that.imgList[index].fullPath,  
                                header: {  
                                    "x-access-token": LoginToken  
                                },  
                                formData: {  
                                    'facility_id': that.facility_detail.facility_id  
                                },  
                                name: 'album_url',  
                                success: (res1) => {  
                                    var res = JSON.parse(res1.data);  
                                    if (res.status == 1 && res.code == 10000) {  
                                        uni.showToast({  
                                            title: '已上传云端相册!',  
                                            icon: 'none',  
                                            success: () => {  
                                                that.downProgressTips = '上传完成';  
                                                uni.hideLoading()  
                                                that.imgList.splice(index, 1)  
                                                that.swpier_id = 0  
                                                if (that.imgList.length == 0) {  
                                                    uni.navigateBack({})  
                                                }  
                                            }  
                                        });  
                                    }  
                                }  
                            });  
                            that.uper.onProgressUpdate(function(res) {  
                                that.percent = res.progress;  
                                that.totalBytesWritten = parseInt(Number(res.totalBytesSent) / 1024) + 'kb'  
                                that.totalBytesExpectedToWrite = parseInt(Number(res.totalBytesExpectedToSend) / 1024) + 'kb'  
                            });
2021-07-15 15:33 负责人:无 分享
已邀请:
DCloud_Android_DQQ

DCloud_Android_DQQ

没太看懂你的意思。你给个能复习问题的demo啊

  • 嘻嘻1004 (作者)

    我测试了一下,我用HBuilderX打包上传指定目录文件是可以的,但是放到离线打包就不行了

    2021-07-15 16:29

  • 嘻嘻1004 (作者)

    上面是我写的上传单个实例,如果我用HBuilderX真机运行测试上传不管多文件还是单文件都可以上传

    但是我用原生studio打包上传是不行的,有什么办法可以解决吗

    2021-07-15 16:35

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

  • 标题 / 粗斜体
  • 代码片段
  • 超链接 / 图片 / 视频
  • 列表 / 引用

文章内容较多时,可以用标题分段 :

## 大标题 
### 小标题

斜体 / 粗体 :

**粗体** 
*斜体*
***粗斜体***

代码片段 :

``` javascript
代码片段
```

超链接 :

[链接文字](链接地址) 例: [百度](http://www.baidu.com)

图片 :

![图片说明](图片地址) 例: ![百度logo](http://www.baidu.com/img/bdlogo.gif)

视频 :

!![视频说明](视频地址) 例: !![优酷视频](http://youku.com)

有序列表 :

1. 123
2. 123
3. 123

无序列表 :

- 123
- 123
- 123

引用 : ( 双回车后结束引用 )

> 引用内容
引用内容
引用内容