This my code for retrieving video from database, while uploading i have copied the video to htdocs folder of mysql and stored the path to the database, while i try to retrieve the video it say an error mime type not matched ,this is my database it has only two column , this is my htdocs folder contains of video
code:
<?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 } } ?>
You need to try to debug your code. Like try to add php generated tag and try to open it in new tab.
<a href="test_upload/uploads/raj.mp4" >test link put in `raj.php` file</a>
I believe you forgot to add starting / so try this link
/test_upload/uploads/raj.mp4
Or use this link:
uploads/raj.mp4
I think in your case its just pathing.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.