How to make CodeIgniter file upload class accept all extensions?
What I do is:
$ext=preg_replace("/.*\.([^.]+)$/","\\1", $_FILES['userfile']['name']);
$fileType=$_FILES['userfile']['type'];
$config['allowed_types'] = $ext.'|'.$fileType;
That makes all files in every function call automatically allowed.
In Codeigniter 2, you simply need to define allowed types like this :
$config['allowed_types'] = '*';
The answer to your direct question: No, there's no way to do this without overriding the core
To good news is you can avoid hacking the core, per the manual
As an added bonus, CodeIgniter permits your libraries to extend native classes if you simply need to add some functionality to an existing library. Or you can even replace native libraries just by placing identically named versions in your application/libraries folder.
So, to have a drop in replacement for your library, you could copy Upload.php to your
application/libraries
folder, and then add your custom logic to that Upload.php file. Code Igniter will include this file instead whenever you load the upload library.
Alternately, you could create your OWN custom uploader class that extends the original, and only refines the is_allowed_filetype function.
application/libraries/MY_Upload.php
class MY_Upload Extends CI_Upload{
function is_allowed_filetype(){
//my custom code here
}
}
You'll want to read over the changelog whenever you're upgrading, but this will allow you to keep your code and the core code in separate universes.