djmzfKnm
djmzfKnm

Reputation: 27195

PHP: Uploading 3gp video files

I want to upload .3gp video files to server via PHP code. I checked the mime type of 3gp video files by 'echo' video type of file, it gives it as application/octet-stream.

I have added a check below to restrict it to only few video format files, as below:

if($_video_type != 'video/x-ms-wmv' && $_video_type != 'application/octet-stream' && $_video_type != 'video/avi' && $_video_type != 'video/mpeg'){
    $_error_videotitle = 'Only WMV, MP4, MPEG, FLV, 3GP videos are allowed';
    $is_errors = true;
}

But its not uploading 3gp file, it still giving error :(

Please help, thanks!

Upvotes: 0

Views: 3063

Answers (2)

Aurel Bílý
Aurel Bílý

Reputation: 7981

This is not a very good check.

Depending on the MIME type (assumably) given by PHP file info is not good at all because it doesn't actually check the contents so much, or not at all...

The MIME type is usually checked by the extension, and there are only few basic extensions supported...

Anything that is defined as "application/octet-stream" is basically in format UNKNOWN to PHP / anything else. Most browsers will just download these kinds of files.

So for actual type and WORKING MIME detection I would suggest to first check the extension, and then a codec that should be contained in a file of that kind. If the headers don't match, the file is not valid... Also - for the headers just search for "3gp format" for example - it is very easy to find formats on most codecs just in Google. If you can't find it like that, check this useful page: Multimedia Wiki

Upvotes: 1

Sarwar Erfan
Sarwar Erfan

Reputation: 18058

Did you copy pasted your code here? If so, then note that you have an additional blank space in the end.

'application/octet-stream '

Upvotes: 2

Related Questions