Error CodeIgniter Library Upload (ECLU)

Hey guys, back again with me, the ultimate troubleshooter.

Damn, I just found a CodeIgniter library upload error, more or less the warning is like the image above, previously it wasn't like that, because I customized my own exception if the process fails, it's simple, just this text;

"Upload failed! - Either image or sound upload failed!"

Error: The filetype you are attempting to upload is not allowed 

Previously, I had activated the CodeIgniter error log by changing it to "development" mode in index.php, then unlocking permission (granting modification permission) in each related directory (in this case ./uploads and ./application/logs). Unfortunately, I got error information that was not relevant to the case above, so I was forced to fix the error that was actually not too fatal.

Okay, moving on, since the error log isn't helpful enough, so I opened the CodeIgniter documentation related to the upload library, there I focused on finding something to display the error related to this library. Okay, I got it, so the capture above is actually after I used this;

$this->upload->display_errors()

But I'm still wondering why it's still an error even though I've added the file format in the upload configuration.

$config['upload_path']          = './uploads/';
$config['allowed_types']        = 'gif|jpg|png|mp3|wav|aac';

Okay, I then checked the mimes.php configuration in CodeIgniter and I found that the *aac format was actually available.

'webm'   =>   'video/webm',
'aac'   =>   'audio/x-acc',
'm4u'   =>   'application/vnd.mpegurl',

I'm annoyed, but why can't I still upload? Next, I'll just check the details of the mimes type of the audio file that I uploaded, using the Linux terminal, please;

file --mime-type yourfile

Okay, now it's clear,

Next, I just added the *aac type to the CodeIgniter mimes.php configuration, so it became like this;

'webm'    =>   'video/webm',
'aac'   =>   array('audio/x-acc', 'audio/x-hx-aac-adts'),
'm4u'   =>   'application/vnd.mpegurl',

The result, boom!

Netizens

Thank you, I have a similar problem with uploading excel files, it turns out that the default mime type in codeigniter for .xlsx files is missing.
The solution is the same, only for the .xlsx extension it can be made like this

'xlsx' => array('application/vnd.openxmlformats-officedocument.spreadsheetml.sheetapplication/vnd.openxmlformats-officedocument.spreadsheetml.sheet', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', 'application/zip', 'application/vnd.ms-excel', 'application/msword', 'application/x-zip'),

Codeigniter version : 3.1.11

Bro, I want to upload an mp4 file, even though the filetype is video/mp4 in mimes.php it is also video/mp4 but it is still not allowed. Is there a solution, bro?

agustriyono4658  Hii agus, I also experienced that before, and it turned out that the mime available in the codeigniter config was not very complete, because there is a unique mime type from the mp4 file, influenced by the device used to produce the file.. please check the actual mime of your mp4 file first via the terminal using the following command..

file --mime-type -b filename

If it turns out that it is not available in your CI config, then please just add it.

Bro, I have uploaded a file in the download menu of my school's CMS website, it says "the file type you are attempting to upload is not allowed" but if I upload a jpg/png file, the upload is successful. Where is this usually the problem, bro...?

AdminMtssAmanahRuteng  what is the CMS, bro? because there are so many CMS platforms, whether it's WordPress, whether it's Edmodo, etc.

If the discussion in this thread is related to the configuration in the CodeIgniter framework... perhaps the CMS you are using is based on CodeIgniter, so just adjust it as your friends did above.


Post a Comment

Previous Next

نموذج الاتصال