Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Codeigniter: MP4 Video Upload not working

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?

like image 968
Ayyaz Zafar Avatar asked Oct 15 '25 15:10

Ayyaz Zafar


2 Answers

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.

like image 74
Ayyaz Zafar Avatar answered Oct 17 '25 06:10

Ayyaz Zafar


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.

like image 38
Mehta Harshit Avatar answered Oct 17 '25 04:10

Mehta Harshit



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!