giao!实现上传照片到服务器,包含删除照片预览照片功能,以及限制上传照片数量。效果图:
post.js
const app = getApp()
var form_data;
var psw_vaule = [];
Page({
data: {
tempFilePaths: [],
img_arr: [],
},
//上传图片到服务器
formSubmit: function () {
var that = this
var adds = that.data.img_arr;
for (var i = 0; i < this.data.img_arr.length; i++) {
wx.uploadFile({
url: 'https:***/submit', //填写实际接口
filePath: that.data.img_arr[i],
name: 'content',
formData: adds,
success: function (res) {
console.log(res)
if (res) {
wx.showToast({
title: '已提交发布!',
duration: 3000
});
}
}
})
}
this