如何在php中检查文件是否为视频类型?

王林
王林 转载
2023-08-19 13:46:01 214浏览

如何在php中检查文件是否为视频类型?

让我们假设以下是我们的变量,其中我们有一个.mp4路径文件−

$movieFileType="demo.mp4";

要检查上述文件是否为视频类型,请使用end()和explode()。您需要在strtolower()中设置此条件并检查条件 −

if(strtolower(end(explode(".",$movieFileType))) =="mp4") {
}
else {
}

Example

<!DOCTYPE html>
<html>
<body>
<?php
$movieFileType="demo.mp4";
if(strtolower(end(explode(".",$movieFileType))) =="mp4") {
   echo "The movie ",$movieFileType," is of video type.";
} else {
   echo "The movie ",$movieFileType," is not of video type.";
}
?>
</body>
</html>

这将产生以下输出 −

输出

The movie demo.mp4 is of video type.

以上就是如何在php中检查文件是否为视频类型?的详细内容,更多请关注php中文网其它相关文章!

声明:本文转载于:tutorialspoint,如有侵犯,请联系admin@php.cn删除