本文共 1985 字,大约阅读时间需要 6 分钟。
视频的出现让网站更加有生有色,对于php上传视频而言,我需要实现多视频上传,视频播放功能,静音功能,全屏播放,下载视频功能等一体的需求,接下来就为大家详细讲解一下如何实现多视频同时上传这样一个功能。具体代码如下:
<form method="POST" name="myform" action="{:U('doeditvideo')}" enctype="multipart/form-data">
<!-- <input type="hidden" value="{$info.id}" name="id" /> --><table class="layui-table" lay-skin="nob" style="width: 1000px;"><tr> <td class="layui-input"><span class="bi_tian"></span>视频:</td><td class="input"><foreach name="imgarr1" item="vv"><video class="min_img" controls src="/Public/Uploads/video/{$vv}" style="width:150px;height:150px;" alt=""></video> </foreach><img src=""></td></tr><tr> <td class="layui-input"><span class="bi_tian"></span>上传视频:</td><td class="input"><input type="file" name="video[]" multiple></td></tr><tr> <td class="layui-input"></td><td class="submit"><input type="submit" value="保存" class="layui-btn"/> </td></tr></table></form>
PHP实现代码:
public function doeditvideo(){
header("Content-type:text/html;charset=utf-8");
$id=I("id");
$data['addtime']=time();
if($_FILES["video"]["name"]!=''){
$arr1=$this->upload1();
$imgstr1="";
foreach($arr1 as $vv){
$imgstr1.=$vv['savename'].',';
}
$imgstr1=trim($imgstr1,',');
$data['video']=$imgstr1;
}else{
$data['video']=0;
}
$model=M('dynamic');
if($model->where("id=$id")->save($data)){
$this->success("成功",U("Dynamic/index"));
}else{
$this->error("发布失败");
}
}
public function upload1(){
import('ORG.Net.UploadFile');
$upload= new UploadFile(); // 实例化上传类
$upload->maxSize = 9999999 ; // 设置附件上传大小
$upload->allowExts = array("vob","ifo","mpg","mpeg","dat","mp4","3gp","mov","rm","ram","rmvb","wmv","asf","avi","asx");
$upload->savePath = './Public/Uploads/video/'; // 设置附件上传目录
$info= $upload->upload();
$arr = $upload->getUploadFileInfo();
return $arr;
}
相信看到这里各位程序开发者应该已经清楚是如何实现了吧,那么大家现在就可以开始尝试一下了,如果还是存在有其他方面疑问的话,可以留言讨论,我们收到留言后会第一时间给出详细的答复。本文由专业的郑州app开发公司燚轩科技整理发布,如需转载请注明出处。
转载于:https://blog.51cto.com/13686158/2139368