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
<view class="page-body-info"> <block wx:if="{{src === ''}}"> <view class="image-plus image-plus-nb" bindtap="chooseVideo"> <view class="image-plus-horizontal"></view> <view class="image-plus-vertical"></view> </view> <view class="image-plus-text">添加视频</view> </block> <block wx:if="{{src != ''}}"> <video src="{{src}}" class="video"></video> </block> </view>
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('接口调用失败') } }) } })
Related recommendations:
WeChat JSSDK upload pictures_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!

本篇文章给大家带来了关于微信小程序的相关问题,其中主要介绍了关于基础架构原理的相关内容,其中包括了宿主环境、执行环境、小程序整体架构、运行机制、更新机制、数据通信机制等等内容,下面一起来看一下,希望对大家有帮助。

本篇文章给大家带来了关于微信小程序的相关知识,其中主要介绍了关于云服务的配置详解,包括了创建使用云开发项目、搭建云环境、测试云服务等等内容,下面一起来看一下,希望对大家有帮助。

本篇文章给大家带来了关于微信小程序的相关知识,其中主要介绍了关于富文本编辑器的实战示例,包括了创建发布页面、实现基本布局、实现编辑区操作栏的功能等内容,下面一起来看一下,希望对大家有帮助。

西安坐地铁用的小程序为“乘车码”。使用方法:1、打开手机微信客户端,点击“发现”中的“小程序”;2、在搜索栏中输入“乘车码”进行搜索;3、直接定位城市西安,或者搜索西安,点击“西安地铁乘车码”选项的“去乘车”按钮;4、根据腾讯官方提示进行授权,开通“乘车码”业务即可利用该小程序提供的二维码来支付乘车了。

本篇文章给大家带来了关于微信小程序的相关问题,其中主要介绍了关于开发工具介绍的相关内容,包括了下载开发工具以及编辑器总结等内容,下面一起来看一下,希望对大家有帮助。

本篇文章给大家带来了关于微信小程序的相关知识,其中主要介绍了怎么实现小程序授权登录功能的相关内容,下面一起来看一下,希望对大家有帮助。


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Dreamweaver Mac version
Visual web development tools

VSCode Windows 64-bit Download
A free and powerful IDE editor launched by Microsoft

MinGW - Minimalist GNU for Windows
This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.
