uniapp圖片上傳,blob的url,使用formdata上傳


這里主要介紹使用form-data的格式進行上傳,

 uni.chooseImage({
     count: 1,
     sizeType: ['original', 'compressed'],
     success: res => {
         uni.uploadFile({
             url: '后端接口地址',
             filePath: res.tempFilePaths[0],
             header: {
	            'Authorization': 'Bearer ' + token.access_token,
	            "Content-Type": "multipart/form-data",
	         },
             formData: {
                 id: 123 // 后端接收的其他參數
             },
             name: 'file', // 后端接收的文件名
             complete: (res) => {
                 console.log('res', res)
             }
         })
     }
 })

https://www.jianshu.com/p/17f22797b52a


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM