手机版

微信小程序tp5上传图片

时间:2021-12-11 来源:互联网 编辑:宝哥软件园 浏览:

test.wxml页面

view class='title '请选择要反馈的问题视图选择器绑定更改=' BindPickerChange '值=' { { index } } '范围=' { { array } } '视图{ { array[index]} }视图图像src='././image/IC _ down。SVG ' class=' picker _ icon '图像pickerviewtextarea占位符='请输入您的意见或建议name='文本区域' bind input='反馈输入'/view class=' title '图片添加view view class=' uploadImg ' view wx : for=' { { image } } ' wx : key=' feedbackImg ' image src=' { { image[index]} ' image button bind tap=' delectImg ' data-num=' { { index } } '删除按钮视图图像' src='././image/IC _ add _ pic。SVG ' bind tap=' uploadImg ' class=' adding ' style=' display : { { img _ button } } ' imageviewputon class=' Submit ' type=' { { button _ status } } ' bind tap=' Submit '提交buttontest.js页面

var app=GetApp();页面({ data: { array: ['程序错误', '软件改善', '业务建议],index:0,msg: ' ',button_status: '默认值',image:[],img_button: '内联块',},bindPickerChange:函数{这个。setdata({ index : e . detail。value });},Submit:函数(e) { if(this.data.msg.length!=0){ var=this;wx.showModal({ title: '提示,content: '是否确认提交?',成功:功能(RES){ if(RES . confirm){ wx。请求({ URL : app。appurl。URL ' advice/uid/' app。appdata。userid '/type/'表示。数据。数组[那个。数据。index]'/content/'该。数据。msg,//pic=图片地址1,图片地址2,图片地址3此处读取图片隐藏域的图片地址,多张用逗号分隔标头: { ' Content-Type ' : ' application/JSON ' },方法: 'POST ',成功:函数(res) { },失败:函数(err) { },完成:函数(RES){ wx。显示吐司({ title : '提交成功,image: '/image/right.png ',持续时间: 3000 })setTimeout(function(){ wx。clearstorage()。wx。navigate back({ delta : { 1 })},2000);},}) },}) } },反馈输入:函数(事件){控制台。日志(事件。细节。价值。长度);if(事件。细节。价值。长度==0){ this。setdata({ button _ status 3360 ' default ',});} else { this。setdata({ button _ status 3360 ' primary ',});}这个。setdata({ msg :事件。细节。value,});},uploadImg:function(){ var即=这个,图像=这个。数据。图像;如果(这个。数据。图像。长度3){ wx。选择图像({ count : 1,//默认9尺寸类型: ['原始','压缩'],//可以指定是原图还是压缩图,默认二者都有sourceType: ['相册','相机'],//可以指定来源是相册还是相机,默认二者都有成功:函数(RES){ wx。uploadfile({ URL : app。appurl。网址'上传',//这个方法就是后台处理上传的方法文件路径: RES . tempfile路径[0],//获取到上传的图片名称:“文件”,成功:函数(信息){控制台。日志(信息);//info.data就是上传成功的图片名称您可以在wxml里面搞一个隐藏域存储起来,在上面使服从提交里拼装一块提交出去} }) },完成:功能(res) { //返回选定照片的本地文件路径列表,tempFilePath可以作为img标签的科学研究委员会属性显示图片如果(那个。数据。图像。长度==2){那个。setdata({ img _ button : ' none ',})}图像。push(RES . tempfile path);that.setData({ image: image,})})},delectimg:函数(e){ var image=this。数据。图像;图像。拼接(例如电流目标。数据集。num,1);this.setData({ image: image,img_button: 'inline-block ',}) },})thinkphp5接受处理

//图片上传公共函数upload(){ $ file=request()-file(' file ');$info=$file-move(ROOT_PATH .公共的DS .上传/图像');if($ info){ echo $ info-getSaveName();die();} else { echo $ file-GetError();die();} } 微信小程序 tp5上传图片(图1) 微信小程序 tp5上传图片(图2)

版权声明:微信小程序tp5上传图片是由宝哥软件园云端程序自动收集整理而来。如果本文侵犯了你的权益,请联系本站底部QQ或者邮箱删除。