2023-08-19

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

如何在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中文网其它相关文章!

https://www.php.cn/faq/593600.html

发表回复

Your email address will not be published. Required fields are marked *