When i try to upload audio file using $audio_file->add_field('audio', array('type' => 'asset','overwrite' => TRUE, 'display_input' => TRUE)); I couldnt able to upload file since it is not saving in assets and db. Please kindly help
Apart from any possible coding errors, you'll probably find that the default settings on your web server has set the upload file size limit much lower than the average MP3 size. I'd double-0check that first...
You may also need to modify the fuel/application/config/mimes.php file to account for your audio file's mime type and/or add the the following to your fuel/application/config/MY_fuel.php file and modify the "assets" to include any extensions (note the {add_your_extensions_here}): // Specifies what filetype extensions can be included in the folders
$config['editable_asset_filetypes'] = array(
'images' => 'jpg|jpeg|jpe|gif|png|zip|svg',
'pdf' => 'pdf|zip',
'media' => 'mov|mp3|aiff|mpeg|zip',
'assets' => 'jpg|jpeg|jpe|png|gif|mov|mpeg|mp3|wav|aiff|pdf|css|zip|svg|{add_your_extensions_here}'
);
This may be off-topic, but I've often had difficulties uploading using Codeigniter's upload class, and it can depend on how the browser identifies the MIME type? Would another browser allow the upload?
I wrote up a technique to identify the MIME being used by the browser here. The problem I had wasn't to do with audio files, but it might help anyway.
It could also be an Apache limitation with the upload max file size. If that isn't set high enough, it may fail silently without an error message. To fix that issue, add the following to your .htaccess: php_value upload_max_filesize 10M
php_value post_max_size 10M http://stackoverflow.com/questions/1122418/changing-upload-max-filesize-on-php
Also, Gumster is right... I've run into this issue as well (e.g. I remember Firefox doing like a zip mime for PDFs or something a while back). I would check out his technique to identify the mime type first and see if it is included in the mimes.php config file.
Comments
// Specifies what filetype extensions can be included in the folders $config['editable_asset_filetypes'] = array( 'images' => 'jpg|jpeg|jpe|gif|png|zip|svg', 'pdf' => 'pdf|zip', 'media' => 'mov|mp3|aiff|mpeg|zip', 'assets' => 'jpg|jpeg|jpe|png|gif|mov|mpeg|mp3|wav|aiff|pdf|css|zip|svg|{add_your_extensions_here}' );
I wrote up a technique to identify the MIME being used by the browser here. The problem I had wasn't to do with audio files, but it might help anyway.
Adding this in mimes for mp3 file is enough right?
php_value upload_max_filesize 10M php_value post_max_size 10M
http://stackoverflow.com/questions/1122418/changing-upload-max-filesize-on-php
Also, Gumster is right... I've run into this issue as well (e.g. I remember Firefox doing like a zip mime for PDFs or something a while back). I would check out his technique to identify the mime type first and see if it is included in the mimes.php config file.