Development code for uploading videos in WeChat applet

PHPz
Release: 2018-09-06 10:54:31
Original
11462 people have browsed it

The content of this article is about the development code for uploading videos in the WeChat applet. It has certain reference value. Friends in need can refer to it. I hope it will be helpful to you.

In fact, this is relatively simple. The official API interface is provided. Basically, you can call it directly. Without further ado, the code is as follows

index.wxml

      添加视频     
Copy after login

index. js

Page({ data: { src: '' }, //选择视频 chooseVideo: function() { var that = this wx.chooseVideo({ success: function(res) { that.setData({ src: res.tempFilePath, }) } }) }, //上传视频 目前后台限制最大100M,以后如果视频太大可以在选择视频的时候进行压缩 uploadvideo: function() { var src = this.data.src; wx.uploadFile({ url: 'http://172.16.98.36:8080/upanddown/upload2',//服务器接口 method: 'POST',//这行好像可以不用 filePath: src, header: { 'content-type': 'multipart/form-data' }, name: 'files',//服务器定义key字段名称 success: function() { console.log('视频上传成功') }, fail: function() { console.log('接口调用失败') } }) } })
Copy after login

Related recommendations:

WeChat JSSDK upload pictures_javascript skills

AJAX asynchronously collects all images from Youku album Video and information (JavaScript code)_javascript skills

The above is the detailed content of Development code for uploading videos in WeChat applet. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!