做爰高潮a片〈毛片〉,尤物av天堂一区二区在线观看,一本久久A久久精品VR综合,添女人荫蒂全部过程av

最新文章專題視頻專題問答1問答10問答100問答1000問答2000關鍵字專題1關鍵字專題50關鍵字專題500關鍵字專題1500TAG最新視頻文章推薦1 推薦3 推薦5 推薦7 推薦9 推薦11 推薦13 推薦15 推薦17 推薦19 推薦21 推薦23 推薦25 推薦27 推薦29 推薦31 推薦33 推薦35 推薦37視頻文章20視頻文章30視頻文章40視頻文章50視頻文章60 視頻文章70視頻文章80視頻文章90視頻文章100視頻文章120視頻文章140 視頻2關鍵字專題關鍵字專題tag2tag3文章專題文章專題2文章索引1文章索引2文章索引3文章索引4文章索引5123456789101112131415文章專題3
問答文章1 問答文章501 問答文章1001 問答文章1501 問答文章2001 問答文章2501 問答文章3001 問答文章3501 問答文章4001 問答文章4501 問答文章5001 問答文章5501 問答文章6001 問答文章6501 問答文章7001 問答文章7501 問答文章8001 問答文章8501 問答文章9001 問答文章9501
當前位置: 首頁 - 科技 - 知識百科 - 正文

微信小程序怎樣使圖片上傳至服務器

來源:懂視網 責編:小采 時間:2020-11-27 19:54:55
文檔

微信小程序怎樣使圖片上傳至服務器

微信小程序怎樣使圖片上傳至服務器:這次給大家帶來微信小程序怎樣使圖片上傳至服務器,微信小程序使圖片上傳至服務器的注意事項有哪些,下面就是實戰案例,一起來看一下。-wxml <view class="shangchuan" bindtap="choose"> <image
推薦度:
導讀微信小程序怎樣使圖片上傳至服務器:這次給大家帶來微信小程序怎樣使圖片上傳至服務器,微信小程序使圖片上傳至服務器的注意事項有哪些,下面就是實戰案例,一起來看一下。-wxml <view class="shangchuan" bindtap="choose"> <image

這次給大家帶來微信小程序怎樣使圖片上傳至服務器,微信小程序使圖片上傳至服務器的注意事項有哪些,下面就是實戰案例,一起來看一下。

-wxml
 <view class="shangchuan" bindtap="choose">
 <image style="width:100%;height:100%;" src="{{tempFilePaths}}"></image>
 </view>
 <button formType='submit' class="fabu">發布項目</button>
 /**選擇圖片 */
 choose: function () {
 var that = this
 wx.chooseImage({
 count: 1,
 sizeType: ['original', 'compressed'], // 可以指定是原圖還是壓縮圖,默認二者都有
 sourceType: ['album', 'camera'], // 可以指定來源是相冊還是相機,默認二者都有
 success: function (res) {
 var tempFilePaths = res.tempFilePaths
 that.setData({
 tempFilePaths: res.tempFilePaths
 })
 console.log(res.tempFilePaths)
 wx.setStorage({ key: "card", data: tempFilePaths[0] })
 }
 })
 },

2.使用wx.uploadFile將剛才上傳的圖片上傳到服務器上

 formSubmit2: function (e) {
 var that = this
 var card = wx.getStorageSync('card')
 wx.uploadFile({
 url: app.globalData.create_funds,
 filePath: card,
 name: 'card',
 formData: {
 'user_id': app.globalData.user_id,
 'person': e.detail.value.person,
 'company': e.detail.value.company,
 },
 success: function (res) {
 console.log(res)
 }
 })
 }
 }
 },

PS: 微信小程序上傳一或多張圖片

一.要點

1.選取圖片

wx.chooseImage({
 sizeType: [], // original 原圖,compressed 壓縮圖,默認二者都有
 sourceType: [], // album 從相冊選圖,camera 使用相機,默認二者都有
 success: function (res) {
 console.log(res);
 var array = res.tempFilePaths, //圖片的本地文件路徑列表
 }
 })

2.上傳圖片

wx.uploadFile({
 url: '', //開發者服務器的 url
 filePath: '', // 要上傳文件資源的路徑 String類型?。。? name: 'uploadFile', // 文件對應的 key ,(后臺接口規定的關于圖片的請求參數)
 header: {
 'content-type': 'multipart/form-data'
 }, // 設置請求的 header
 formData: { }, // HTTP 請求中其他額外的參數
 success: function (res) {
 },
 fail: function (res) {
 }
 })

二.代碼示例

// 點擊上傳圖片
upShopLogo: function () {
 var that = this;
 wx.showActionSheet({
 itemList: ['從相冊中選擇', '拍照'],
 itemColor: "#f7982a",
 success: function (res) {
 if (!res.cancel) {
 if (res.tapIndex == 0) {
 that.chooseWxImageShop('album') 
 } else if (res.tapIndex == 1) {
 that.chooseWxImageShop('camera')
 }
 }
 }
 })
 },
 chooseWxImageShop: function (type) {
 var that = this;
 wx.chooseImage({
 sizeType: ['original', 'compressed'],
 sourceType: [type],
 success: function (res) {
/*上傳單張
 that.data.orderDetail.shopImage = res.tempFilePaths[0],
 that.upload_file(API_URL + 'shop/shopIcon', res.tempFilePaths[0])
*/
 /*上傳多張(遍歷數組,一次傳一張)
 for (var index in res.tempFilePaths) {
 that.upload_file(API_URL + 'shop/shopImage', res.tempFilePaths[index])
 }
*/
 }
 })
 },
upload_file: function (url, filePath) {
 var that = this;
 wx.uploadFile({
 url: url,
 filePath: filePath,
 name: 'uploadFile',
 header: {
 'content-type': 'multipart/form-data'
 }, // 設置請求的 header
 formData: { 'shopId': wx.getStorageSync('shopId') }, // HTTP 請求中其他額外的 form data
 success: function (res) {
 wx.showToast({
 title: "圖片修改成功",
 icon: 'success',
 duration: 700
 })
 },
 fail: function (res) {
 }
 })
 },

相信看了本文案例你已經掌握了方法,更多精彩請關注Gxl網其它相關文章!

推薦閱讀:

在ES6里模板字符串使用詳解

在Bootstrap里怎么操作table

聲明:本網頁內容旨在傳播知識,若有侵權等問題請及時與本網聯系,我們將在第一時間刪除處理。TEL:177 7030 7066 E-MAIL:11247931@qq.com

文檔

微信小程序怎樣使圖片上傳至服務器

微信小程序怎樣使圖片上傳至服務器:這次給大家帶來微信小程序怎樣使圖片上傳至服務器,微信小程序使圖片上傳至服務器的注意事項有哪些,下面就是實戰案例,一起來看一下。-wxml <view class="shangchuan" bindtap="choose"> <image
推薦度:
標簽: 照片 圖片 小程序
  • 熱門焦點

最新推薦

猜你喜歡

熱門推薦

專題
Top
主站蜘蛛池模板: 望城县| 浠水县| 上蔡县| 黄骅市| 衡阳县| 临沂市| 寻乌县| 乐平市| 禹城市| 清原| 喀什市| 乌兰浩特市| 淄博市| 华蓥市| 白朗县| 湾仔区| 海淀区| 外汇| 射阳县| 横峰县| 晋江市| 虞城县| 临澧县| 鹤壁市| 开化县| 繁峙县| 绥德县| 汨罗市| 乌海市| 伽师县| 分宜县| 射阳县| 当雄县| 崇阳县| 晋中市| 三原县| 竹溪县| 通榆县| 乌恰县| 建瓯市| 岑巩县|