当前位置:网站首页>Uni app upload file
Uni app upload file
2022-06-13 06:05:00 【Jiuwujiuwu】
<view class="img" @tap="getUploadImg">
<image :src='list.logo'></image>
</view>
getUploadImg(e) {
uni.chooseImage({
count: 1, // Default 9
sizeType: ['compressed'],
sourceType: ['album'],
success: (res) => {
var tempFilePaths = res.tempFilePaths;
uni.showLoading({
mask: true
})
var params = {
url: "/p/file/upload",
filePath: tempFilePaths[0],
name: 'file',
callBack: (res2) => {
uni.hideLoading();
this.list.logo = JSON.parse(res2).resourcesUrl + JSON.parse(res2)
.filePath,
this._photoFiles = JSON.parse(res2).filePath
this.isChange = true
},
};
http.upload(params);
},
fail: (failMsg) => {
console.log(failMsg)
}
})
},
Unified interface for uploading files
/** * Unified interface for uploading files */
function upload(params) {
console.log(params)
wx.uploadFile({
url: config.domain + params.url,
filePath: params.filePath,
name: params.name,
header: {
'Authorization': params.login ? undefined : wx.getStorageSync('token')
},
formData: params.formData,
dataType: 'json',
responseType: params.responseType == undefined ? 'json' : params.responseType,
success: function(res) {
console.log(res,'------------')
if (res.statusCode == 200) {
// If there is a definition params.callBack, Call params.callBack(res.data)
if (params.callBack) {
params.callBack(res.data);
}
}
},
fail: function(err) {
uni.hideLoading();
}
});
}
边栏推荐
- Leetcode- third largest number - simple
- ArrayList loop removes the pit encountered
- Kotlin learning notes (1)
- Leetcode planting flowers - simple
- 【自动化测试】Cypress手册
- Leetcode judge subsequence simple
- After MySQL is installed, enter the "net start MySQL" command, and an error is reported that "net" is neither an internal or external command nor a runnable program
- Leetcode- minimum number of operations to make array elements equal - simple
- Test logiciel - résumé des FAQ d'interface
- Essays on November 5, 2021
猜你喜欢

MySQL stored procedure

HBuilderX:HBuilderX安装以及其常用插件安装

Four shardingsphere JDBC sharding strategies

Function and application scenario of field setaccessible() method

Sentinel series hot spot current limiting

Echart折线图:当多条折线图的name一样时也显示不同的颜色

Tongweb card, tongweb card, tongweb card

零拷贝技术
![[turn] explain awk (1)__ Awk Basics_ Options_ Program segment parsing and examples](/img/65/a214d137e230b1a1190feb03660f2c.jpg)
[turn] explain awk (1)__ Awk Basics_ Options_ Program segment parsing and examples

Config server configuration center of Nacos series
随机推荐
[spark]spark introductory practical series_ 8_ Spark_ Mllib (upper)__ Introduction to machine learning and sparkmllib
Status management --provider
自我总结ing
Introduction to USB learning (I) -- Dongfeng night flower tree
【MySQL】基础知识小复习
ArrayList loop removes the pit encountered
Working principle of sentinel series (concept)
php redis 制作高迸发秒杀
Missing tag identification in cots RFID systems: bringing the gap between theory and Practice
Working principle of sentinel series (source code analysis)
Leetcode- student attendance record i- simple
Sqlplus connection failure
Leetcode judge subsequence simple
Ffmpeg download suffix is Video files for m3u8
Leetcode- detect uppercase letters - simple
Exception after repeated application redeployment on tongweb: application instance has been stopped already or outofmemoryerror:metaspace
Experience of redis installation under Linux system (an error is reported at the same time. The struct redis server does not have a member named XXXX)
[compilation and assembly link] coff file and structure description
[automated test] cypress manual
Tongweb customs clearance guidelines