Welcome Guest, Not a member yet? Register   Sign In
MP3 upload little issue.
#1

[eluser]Unknown[/eluser]
Hi everyone,

I've been trying to upload an MP3 file using the CI's file upload class, but I keep getting the following error; "The filetype you are attempting to upload is not allowed.".

The relevant config information is:
Code:
$config = array();
$config['upload_path'] = 'application/audio';
$config['allowed_types'] = 'mp3';

And the file information is:
Code:
Array
(
    [file_name] => 16_Track 16.mp3
    [file_type] => audio/mpeg
    [file_path] => /home/blazing/public_html/application/audio/
    [full_path] => /home/blazing/public_html/application/audio/16_Track 16.mp3
    [raw_name] => 16_Track 16
    [orig_name] =>
    [file_ext] => .mp3
    [file_size] => 66
    [is_image] =>
    [image_width] =>
    [image_height] =>
    [image_type] =>
    [image_size_str] =>
)

I've tried also writing the actual mime types (audio/mpeg, audio/x-mpeg, audio/mp3, audio/x-mp3, audio/mpeg3, audio/x-mpeg3, audio/mpg, audio/x-mpg, audio/x-mpegaudio) on the "allowed_types" but nothing seems to work.

If someone went through this before, or knows a solution please let me know. I'd really appreciate any help.

Thanks in advance.
#2

[eluser]JoostV[/eluser]
Echo the mime type and see if the correct type is in /config.mimes.php. If not, add it. The mime types codeigniter recognizes as mp3 are by default 'audio/mpeg' and 'audio/mpg'

Code:
// Echo mime type after upload
$field = 'your_upload_field_name_here';
var_dump($_FILES[$field]['type'])

Different browsers tend to send different mime type headers on upload. Every time a new browser version is released you may have to alter your mimes.php file. This can be a real pain.
#3

[eluser]Unknown[/eluser]
Thanks, that solved it.
The mime type was missing on the list.




Theme © iAndrew 2016 - Forum software by © MyBB