1
votes

when I run this script to find out the MIME type of files the MIME type returned for .f4v files are returned as application/octet-stream and not video/mp4. This makes it impossible to upload .fv4 files on my site as the critira are for files to either have a MIME type of video/mp4,video/x-flv or video/webm. is there a way around this?

<?php

   $fileName = "file.f4v";
   $finfo = finfo_open(FILEINFO_MIME_TYPE);
   $mime = finfo_file($finfo, $fileName);
?> 
2

2 Answers

3
votes

I am having a very similar problem with a media upload form that was originally configured to filter uploads by MIME type, a rule that in the end had to be completely scrapped.

The problem is, you cannot force a user agent to correctly indicate the MIME type of a file it is uploading. And lots of files end up uploaded with MIME types you wouldn't expect. Thus, you cannot depend on MIME types submitted with file uploads as a criterium for determining the type of the files.

My solution is to simply depend on file extensions and use MIME type as a fallback only for files without extensions.

0
votes

add mime type "video/x-f4v" to webserver