小程序中上传图片到服务器

wx .uploadFile ({
url : 'http://192.168.3.12:19080/staticData/api/v1/cloud/mgr/uploadFile' ,
// url: 'http://192.168.3.253:8001/api/v1/cloud/mgr/uploadFile',
filePath : tempFilePaths [ 0 ],
name : 'file' ,
formData : {
'user' : 'test' ,
cloudType : 3 ,  //int Y 云服务商类型,1-七牛云,2-QQ云,3-阿里云,4-AWS S3
resType : 1 ,  //int Y 云上传类型,1-图片,2-视频,3-数据文件,4-其他
key : 'crm/partner/' + timeMark + imgType ,  //String  Y 云存储的key
file : tempFilePaths [ 0 ]   //File  Y 上传的文件
},
header : {
'content-type' : 'application/x-www-form-urlencoded'
},
// {"error_info": "http://ddp-imgsoss-cn-hangzhou.aliyuncs.com/crm/partner/39035115.jpg", "error_code": 0 }
method : 'post' ,
success : function (ress ) {
var data = JSON .parse (ress .data ).error_info ;
var url = 'http://ddp-imgs.oss-cn-hangzhou.aliyuncs.com:80' + data .substring (data .lastIndexOf ( "/crm" ), data .length );
var urlImg = 'markImgUrl[' + index + ']' ;
console .log (url );
//do something
that .setData ({
[urlImg ]: url
})
console .log (that .data .markImgUrl );
}, fail : function (err ) {
console .log (err )
}
})
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值