tp5 视频上传及展示
//渲染视频页面
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= hinkDb::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>声明:该文观点仅代表作者本人,入门客AI创业平台信息发布平台仅提供信息存储空间服务,如有疑问请联系rumenke@qq.com。
- 上一篇: tp5添加 上传图片
- 下一篇: tp5 修改
