我有一个上传视频的页面,我希望文件类型是mp4 flash和webm文件 . 所有的mp4扩展文件和webm文件工作正常,但flash文件(.flv和.f4v)无法识别,因此php返回值'application / octet-stream',我认为这是任何文件的默认MIME认识到了 . 有没有比这个代码更好的方法来识别真正的MIMES(video / x-flv和video / x-f4v)的flash文件?
$type = $_FILES["uploaded"]["type"];
$allowedTypes = ["video/mp4","video/quicktime","video/x-flv","video/x- f4v",
"video/webm"];
$isRefusedType = !in_array($type, $allowedTypes);
if ($isRefusedType)
{
$message="not an accepted file type";
}
else $message="OK";
2 回答
也许你可以试试这段代码:
如here所述,您将需要PHP> = 5.3.0,这是一个问题吗?
Another idea 可能是检查数据签名(见there):
看一下php文档中$ _FILES ['userfile'] ['type']的描述,我们可以看到:
所以Tiger-222选项似乎是获得真正 Value 的最佳机会: