Welcome Guest, Not a member yet? Register   Sign In
uploading video files
#1

[eluser]Unknown[/eluser]
Hello.
If I get it right, codeigniter's upload class uses mime types described in config in allowed_types.

At first the upload class watches the extension of the file, and then the mime-type of file. I need to allow to upload only popular video formats. But there is a problem: if I have, say, .mpg file with mime-type application/octet-stream, or another, the file won't be uploaded.

What is the best solution to allow to upload only some popular video formats? Is it possible to check only mime-types (for example if I downloaded video from youtube with x-flv mime, and saved it like my_video.mpg, the upload class will check only 'x-flv' mime and download it)? But application/octet-stream is also the mime for .dll and another not-video formats.

Basically my task is: to allow to upload different video files, then convert them to .flv and .mpg. And disallow to upload .txt, .dll, .whatever.. Smile

What I did:
Code:
'avi' => 'video/x-msvideo',
    'mp4' => 'video/mp4',
    '3gp' => 'video/3gpp',
    'mpeg' => array('video/mpeg', 'application/octet-stream'),
    'mpg' => array('video/mpeg', 'application/octet-stream'),
    'mov' => 'video/quicktime',
    'mp3' => array('audio/mpeg', 'audio/mpg', 'audio/mpeg3', 'audio/mp3', 'video/mpeg', 'video/x-mpeg'),
    'flv'   => array('video/flv', 'video/x-flv', 'flv-application/octet-stream', 'application/octet-stream'),  
    'wmv'   => array('video/wmv', 'video/x-ms-wmv', 'flv-application/octet-stream', 'application/octet-stream')
and
Code:
$config['allowed_types'] = 'avi|mp4|3gp|mpeg|mpg|mov|mp3|flv|wmv';

for upload class. Firstly it was 'mpg' => 'video/mpeg', but I get an error that the file which I tried to upload had application/octet-stream mime, so I added it to config.

Thanks in advance & sorry for my poor english
#2

[eluser]Nonox[/eluser]
I'm not sure if is the same problem, anyway.

I had a problem when I tried to upload .epub files through the Codeigniter File Uploading Class, I always recived the massage The filetype you are attempting to upload is not allowed., what I did was to add the mime type into the /applications/config/mimes.php file.

In my case was this new key in the array:
Code:
'epub' => 'application/octet-stream'

By the way, I'm using CI 2.1.

NB
#3

[eluser]Unknown[/eluser]
mpg into mov: <a href="http://www.ilikemall.com/how-to/convert-mpg-to-mov-mac.html">http://www.ilikemall.com/how-to/convert-mpg-to-mov-mac.html</a>
#4

[eluser]Unknown[/eluser]
It's recommend to convert your video to popular video formats using Video Converter Assist program, before uploading them. Because there might be many video format that the file uploading class can't recognize.
#5

[eluser]Unknown[/eluser]
Thanks (bobpeter) the information you have provide on converter is helpful.




Theme © iAndrew 2016 - Forum software by © MyBB