我正在尝试通过3.php和4.php上传视频文件(Mp4)。上传的vidio文件以正确的大小正确存储在/ upload目录中。
我的问题是,当我尝试使用我的php程序5.php播放上传的文件时,它会显示没有任何图片或语音的黑屏播放。
我检查了原始文件,这很好。
<html>
<body>
<form action="4.php" method="post" enctype="multipart/form-data">
<label for="file">Filename:</label>
<input type="file" name="file" id="file" />
<br />
<input type="submit" name="submit" value="Submit" />
</form>
</body>
</html>
<?php
$allowedExts = array("jpg", "jpeg", "gif", "png", "mp4");
$extension = end(explode(".", $_FILES["file"]["name"]));
if ($_FILES["file"]["type"] == "video/mp4")
{
if ($_FILES["file"]["error"] > 0)
{
echo "Return Code: " . $_FILES["file"]["error"] . "<br />";
}
else
{
echo "Upload: " . $_FILES["file"]["name"] . "<br />";
echo "Type: " . $_FILES["file"]["type"] . "<br />";
echo "Size: " . ($_FILES["file"]["size"] / 1024) . " Kb<br />";
echo "Temp file: " . $_FILES["file"]["tmp_name"] . "<br />";
if (file_exists("upload/" . $_FILES["file"]["name"]))
{
echo $_FILES["file"]["name"] . " already exists. ";
}
else
{
move_uploaded_file($_FILES["file"]["tmp_name"],
"upload/" . $_FILES["file"]["name"]);
echo "Stored in: " . "upload/" . $_FILES["file"]["name"];
}
}
}
else
{
echo "Invalid file";
}
?>
<?php
$filename = "04072012033.mp4"; // This is uploaded finename.
?>
<div class="form-group">
<video width="300" controls>
<source src="./upload/<?php echo $filename; ?>" type="video/mp4">
<source src="./upload/<?php echo $filename; ?>" type="video/webm">
<source src="./upload/<?php echo $filename; ?>" type="video/ogg">
</video>
</div>
提前致谢