在手机端使用layui的文件上传包括(视频与音频)

首先引入layui的js与css

<script src="https://www.layuicdn.com/layui/layui.js"></script>
<link rel="stylesheet" href="https://www.layuicdn.com/layui/css/layui.css">
 
在script标签中添加 如下代码
  layui.use('upload', function () {
            var $ = layui.jquery,
                upload = layui.upload;
            upload.render({
                elem: '#test6',
                url: api + '/upload',
                accept: 'audio' //音频
                    ,
                done: function (res) {
                    layer.msg('上传成功');
                    happenAudio = res.data.downloadUrl
                  
                }
            });
            upload.render({
                elem: '#test5',
                url: api + '/upload',
                accept: 'video' //视频
                    ,
                done: function (res) {
                    layer.msg('上传成功');
                    
                }
            });
        });
 
 
视图层添加
  <van-button size="small" type="info" id="test5" class="sendcode">
                                上传视频
                            </van-button>
                            <span id="spspan"></span>
span是用来存放上传之后的视频url 
 
posted @ 2021-03-12 11:30  高手坟墓丶  阅读(1172)  评论(0编辑  收藏  举报
-->