Reputation: 2163
I am researching on a problem for long time but still could not find any solution.
I am uploading mp4 file using codeigniter.
Before that I added mime type for mp4 in config/mimes.php.
I tried both: mp4 => video/mp4
and
mp4 => array('video/mp4', 'video/3gpp')
Both of these works perfect in Local server but whenever I test this on the Live server then It always give the same error message "The filetype you are attempting to upload is not allowed.".
I tried one more thing. i.e.
$config['allowed_types'] = "*";
It works perfect in both local and online server.
But I want just mp4 video type.
Anybody have some solution for this strange problem?
Upvotes: 4
Views: 13850
Reputation: 521
Upvotes: 0
Reputation: 314
I depend on video mime file types when we upload video with extension mp4 but in CodeIgniter upload library use php function finfo_file for detect file_type by this function we get other file_type. Ex. I get video/3gpp
So I changed in config/mimes.php
'mp4' => array('video/mp4', 'video/3gpp'),
and its working for me.
Thanks
Upvotes: 0
Reputation: 2163
Finally I got solution of my Problem so I am writing this answer.
Mostly detection of mime types in local and online server are different.
In my case, Local server was getting file_type as "video/mp4". But online server was detecting the mime type as 'application/octet-stream'.
So I added both in array in the mime type list in my config folder:
'mp4' => array('video/mp4', 'application/octet-stream'),
Now it works perfectly in both local and online server.
Upvotes: 8
Reputation: 140
If everything doesn't work, rearrange the allowed type order like this, placing the video format first:
$config['allowed_types'] = 'mp4|jpg|png|'
It works in my case.
Upvotes: 1