gpt4 book ai didi

php - 如何在php中从mysql数据库检索视频路径并像youtube一样显示视频?

转载 作者:行者123 更新时间:2023-11-29 07:29:20 24 4
gpt4 key购买 nike

我已将视频路径存储在 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>

最佳答案

用我的代码替换你的 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>

关于php - 如何在php中从mysql数据库检索视频路径并像youtube一样显示视频?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33273880/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com