WeChat applet to upload files to the server

WeChat small program how to make the picture uploaded to the server

This time to bring you WeChat small program how to make the picture uploaded to the server, WeChat small program to make the picture uploaded to the server of the precautions, the following is the case of the actual practice, together with a look.

-wxml

<viewclass=”shangchuan “bindtap=”choose”>

<imagestyle=”width:100%;height:100%; “src=”{{ tempFilePaths}}”></image>

</view>

<buttonformType=’submit’class=”fabu”>Publish Item</button>

/**chooseImage**

choose:function(){

varthat=this

wx.chooseImage({

count:1,

sizeType:[‘original’,’compressed ‘],//can specify whether it is original or compressed, defaults to both

sourceType:[‘album’,’camera’],//can specify whether the source is album or camera, defaults to both

success:function(res){

vartempFilePaths=res.tempFilePaths

that.setData({

tempFilePaths:res.tempFilePaths

})

console.log(res. tempFilePaths)

wx.setStorage({key: “card”,data:tempFilePaths[0]})

}

}

})

},

2. Use wx.uploadFile to upload the image you just uploaded Upload the image you just uploaded to the server

formSubmit2:function(e){

varthat=this

varcard=wx.getStorageSync(‘card’)

wx.uploadFile({

url: app.globalData.create_card.data),

Wx.uploadFile({

url. app.globalData.create_funds,

filePath:card,

name: ‘card’,

formData:{

‘user_id’:app.globalData.user_id,

< p>‘person’:e.detail.value.person,

‘company’:e.detail.value.company,

},

success:function(res){

console.log( res)

}

})

}

}

}

},

PS: WeChat applet uploads one or more images

I. Key points

1. choose image

wx.chooseImage({

sizeType:[],//original original image, compressed compressed image, default both

sourceType:[],//album from the album to choose the image, camera use camera, default both

success:function(res){

console.log(res);

vararray=res.tempFilePaths,//list of local file paths for images

}

})

})

2. Upload images

wx.uploadFile({

url:”,//developer server url

filePath:”,//path to upload file resource String type!!!

NOTE: ”,//path to upload file resource!

name:’uploadFile’,//key corresponding to the file, (request parameter specified by the backend interface about the image)

header:{

‘content-type’:’multipart/form-data’

},//set the requested header

formData:{},//other extra parameters in the HTTP request

success:function(res){

},

fail:function(res){

}

})

two . Code example

//Click to upload a picture

upShopLogo:function(){

varthat=this;

wx.showActionSheet({

itemList:[‘Select from Albums’,’Take Photo’],

itemColor: “#f7982a”,

success:function(res){

if(!res.cancel){

if(res.tapIndex==0){

that. chooseWxImageShop(‘album’)

}elseif(res.tapIndex==1){

that.chooseWxImageShop(‘camera’)

}

}

}

}

}})

},

chooseWxImageShop:function(type){

varthat=this;

wx.chooseImage({

sizeType:[‘original’,’ compressed’],

sourceType:[type],

success:function(res){

/*Upload leaflet

that.data.orderDetail.shopImage=res. tempFilePaths[0],

that.upload_file(API_URL+’shop/shopIcon’,res.tempFilePaths[0])

*

/*Upload Multiple (iterate through the array, one at a time)

for (varindexinres.tempFilePaths){

that.upload_file(API_URL+’shop/shopImage’,res.tempFilePaths[index])

}

*/

}< /p>

})

},

upload_file:function(url,filePath){

varthat=this;

wx.uploadFile({

url:url,

filePath:filePath,

name:’uploadFile’,

header:{

‘content-type’:’multipart/form-data’

},//Set the request’s header

formData:{‘shopId’:wx.getStorageSync(‘shopId’)},//other extra formdata in HTTP request

success:function(res){

wx.showToast({

title: “Image modified successfully”,

icon:’success’,

ration:700

})

},

fail:function(res){

}

})

Recommended reading:

Using template strings in ES6

How to manipulate table in Bootstrap

What do you need to install to upload photos from wechat applet to aliyun linux server

npminit. wechat applet to upload photos to aliyun linux server you need to install npminit in order to upload stably. WeChat is a free application launched by Tencent on January 21, 2011 to provide instant messaging services for smart terminals.

Apple 13 WeChat app how to upload files from cloud drive

You can store them.

First, find a file in WeChat and click to open it. After the jump, click on the symbol in the upper right corner. Then click “Open with another app” and select “Store to file” in the pop-up window. Then, click on “iCloud”. Select one of the folders to save. In this way, the files in WeChat will be saved to iCloud.

iCloud is a private cloud service provided by Apple that allows users to store up to 5GB of data for free, making it easy for Apple users to share their personal data across devices. iCloud supports the ability to sync and push data wirelessly between user devices, making it easier to use and more convenient than Apple’s traditional iTunes solution (which requires a cable connection). iCloud supports wireless synchronization and push data between user devices, which is easier to operate and has a better user experience than Apple’s traditional iTunes solution (which requires a cable connection).