Search code examples
sqlcodeigniterfile-uploadfile-type

Codeigniter not accepting sql in allowed_filetypes for upload despite mime fix


Codeigniter (latest version) keeps spitting out "The filetype you are attempting to upload is not allowed" when trying to use 'sql' as the allowed filetype in $config['allowed_types'].

I've added 'sql' => 'text/x-sql' to mimes.php config file and verified the browser is indeed recognizing the sql file as being of type text/x-sql but still, no luck.

Is there anything else I can check to get this working? I'd rather not use * for allowed file types if possible.


Solution

  • I know this sounds really crazy but I would make the rule to accept anything (*) and I would check for extension (in this case *.sql). Reason why is simple, browser sets mimetype and I can not rely on that...

    But please try following mimetypes application/octet-stream and of course text/plain.

    You can check mimetype with $_FILES['userfile']['type']