这是我从数据库中检索视频的代码,在上传时我已将视频复制到mysql的htdocs文件夹并将路径存储到数据库中,而我尝试检索视频时发出错误mime type not matched,这个是我的数据库it has only two column,this is my htdocs folder contains of video
代码:
<?php
error_reporting(1);
$servername="localhost";
$username="root";
$password="";
$dbname="demo1";
$conn=new mysqli($servername,$username,$password,$dbname);
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
extract($_POST);
$target_dir = "uploads/";
$target_file = $target_dir . basename($_FILES["fileToUpload"]["name"]);
if($upd)
{
$imageFileType = pathinfo($target_file,PATHINFO_EXTENSION);
if($imageFileType != "mp4" && $imageFileType != "avi" && $imageFileType != "mov" && $imageFileType != "3gp" && $imageFileType != "mpeg")
{
echo "File Format Not Suppoted";
}
else
{
$video_path=$_FILES['fileToUpload']['name'];
$sql = "INSERT INTO video (path) VALUES('$video_path')";
if ($conn->query($sql) === TRUE) {
echo "New record created successfully";
} else {
echo "Error: " . $sql . "<br>" . $conn->error;
}
move_uploaded_file($_FILES["fileToUpload"]["tmp_name"],$target_file);
echo "uploaded ";
}
}
//display all uploaded video
if($_POST['disp'])
{
// echo "came in";
$query=mysqli_query($conn,"select * from video");
while($all_video=mysqli_fetch_array($query))
{
//echo "test_upload/uploads/".$all_video['path'];
?>
<h1>test_upload/uploads/<?php echo $all_video['path']; ?></h1>
<video width="300" height="200" controls>
<source src="test_upload/uploads/<?php echo $all_video['path']; ?>" type="video/mp4">
</video>
<?php } } ?>
答案 0 :(得分:0)
您需要尝试调试代码。就像尝试添加php生成的标签并尝试在新标签中打开它一样。
<a href="test_upload/uploads/raj.mp4" >test link put in `raj.php` file</a>
我相信你忘记添加开始/所以试试这个链接
/test_upload/uploads/raj.mp4
或使用此链接:
uploads/raj.mp4
我认为在你的情况下它只是正确的路径。