layui视频上传
<div class="form-group"> <label class="col-sm-3 control-label">会议视频:</label> <div class="col-sm-8"> <div class="layui-form-item" id="videoUp"> <input name="filed2" id="videourl" autocomplete="off" class="layui-input" type="hidden"> <button type="button" class="layui-btn" id="video"> <i class="layui-icon"></i>上传视频 </button> <div style="margin-top: 10px"> <video id="demo10" height="500" style="max-width: 400px;width: 100%;visibility: hidden" controls autobuffer></video> </div> </div> </div> </div>
layui.use('upload',function(){ var $ = layui.jquery ,upload = layui.upload; //上传视频 var uploadInst=upload.render({ elem: '#video' ,url: prefix + '/uploadFile' ,field:"file" ,data:{"dir":"media"} ,accept: 'video' //视频 ,done: function(r){ if (r.code > 0){ return layer.msg('上传失败,请重新上传!'); } $("#videourl").val(r.url); $("#demo10").css("visibility","visible").append("source").attr("src",r.url).attr("type","video/mp4"); //layer.alert("上传成功",{offset:['200px','450px'],icon:6}); } ,error:function (r) { //演示失败状态,并实现重传 layer.msg(r.msg); } }); });