我已将视频路径存储在mysql数据库&实际视频存储在上传文件夹中,但我想使用数据库路径在我的页面中显示带有控件的视频。
我试过但视频没有加载该视频。
我在控制台中看到以下错误,
获取http://localhost/new_ci/admin/%3C?= $ video_path;?%3E 403(禁止)
请向我建议..?
尝试以下代码:
<?php
$con=mysql_connect("localhost","root","");
mysql_select_db("demo",$con);?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
</head>
<body>
<div id="body">
<table width="80%" border="1">
<tr>
<th colspan="4">your uploads...<label><a href="index.php">upload new files...</a></label></th>
</tr>
<tr>
<td>View</td>
</tr>
<?php
$sql="SELECT * FROM video";
$result_set=mysql_query($sql);
while($row=mysql_fetch_array($result_set))
{
$pat ="upload/";
$pat1 ="http://localhost/new_ci/admin/upload/";
$path = $row['video_name'];
$vid = $pat1.$path
?>
<tr>
<td>
<?php
echo "<embed src=".$vid." />";
echo "<video width='320' height='240' controls> <source src=".$pat.$path." type='video/mp4'>Your browser does not support the video tag.</source></video>"; ?>
<video width="320" height="240" controls> <source src="upload/How To Host A PHP Website From Your Home Computer (Localhost).mp4" type="video/mp4">Your browser does not support the video tag.</source></video>
</td>
</tr>
<?php
}
?>
</table>
</div>
</body>
</html>
&#13;
答案 0 :(得分:2)
用我的代码替换你的td:
<td>
<embed src="<?php echo $vid ?>">
<video width='320' height='240' controls> <source src="<?php echo $vid ?>" type='video/mp4'>Your browser does not support the video tag.</source></video>
<video width="320" height="240" controls> <source src="upload/How To Host A PHP Website From Your Home Computer (Localhost).mp4" type="video/mp4">Your browser does not support the video tag.</source></video>
</td>