如何在php中检查文件是否为视频类型? [英] How to check a file is video type or not in php?
本文介绍了如何在php中检查文件是否为视频类型?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有以下脚本:
function listFolderFiles($dir){
$ffs = scandir($dir);
echo '<ol>';
foreach($ffs as $ff){
if($ff != '.' && $ff != '..'){
echo '<li>'.$ff;
if(is_dir($dir.'/'.$ff)) listFolderFiles($dir.'/'.$ff);
echo '</li>';
}
}
echo '</ol>';
}
listFolderFiles('upload');
我的问题是我想检测文件是视频(mp4或mov)类型,如何检测$ ff是不是视频类型?
My question is I want to detect a file is video(mp4 or mov)type, How i can detect $ff is a video type or not?
推荐答案
if(end(explode(".",$ff)) =="mp4")
{
echo "its an mp4 movie";
}
对于扩展名不区分大小写的版本,您可以找到
There you go, for case insensitive version of the extension
<?php
$ff="abc.MP4";
if(strtolower(end(explode(".",$ff))) =="mp4")
{
echo "its an mp4 movie";
}
?>
这篇关于如何在php中检查文件是否为视频类型?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文