tp5 视频上传及展示
来源:互联网 发布:网络舆情信息 编辑:程序博客网 时间:2024/06/05 09:02
//渲染视频页面public function upload(){return $this->fetch('up');}//视频展示public function listv(){$re=Db::query('select * from sg_fruits where f_id = 78');$this->view->engine->layout(true); $res=$re[0]['f_img'];$this->assign('res',$res);return view();}
<form action="{:url('index/Goods/jie')}" method="post" enctype="multipart/form-data"> <input type="file" name="file" > <input type="submit" value="上传"></form>//接上传的值public function jie(){//print_r($_FILES["file"]);die;$myfile=$_FILES["file"];$tmp=$myfile['tmp_name'];$a='uploads/'.time().'.mp4';$path=ROOT_PATH .'public/'.$a ; $data['f_img']=$a;if(!move_uploaded_file($tmp,$path)) die('视频上传失败');$num= \think\Db::table('sg_fruits')->insert($data);if($num){$this->redirect("goods/listv");}}
<!doctype html><html lang="en"><head> <meta charset="UTF-8"> <title>Document</title></head><body><table> <tr> 视频播放 <video width="320" height="240" controls="controls" src="{$res}"> </video> </tr></table></body></html>
0 0