all mime types to upload |
[eluser]Unknown[/eluser]
Hi All, i have question on upload file class. here we can set the mime types we want to upload :$config['allowed_types']='gif|jpg|png|'; what if i want to upload all the mime types?should i write them the in $config['allowed_types']?or there is a way to tell all the types!!! Thanks.
[eluser]Derek Allard[/eluser]
I can't think of any built in preference to allow this - are you sure that you want to allow any possible file? Executables, viruses, etc? The CI mime type detection isn't perfect, but its a very large step in the right direction. That said, if you've already authenticated users or something, then here's how you can do it. Create a copy of the file called Upload.php (in the libraries folder) and save it in application/libraries (you may need to create this folder). Look through it, and find the function is_allowed_filetype() and replace it with this Code: function is_allowed_filetype() I haven't tested, but what should happen is that CI will preferentially use your library, and your library always says the file is good. Hope this is helpful.
[eluser]Michael Wales[/eluser]
coolfactor posted a nice piece of code over in another thread Code: class MY_Upload extends CI_Upload { This allows you to not entirely ditch the filetype permissions. If you do define allowed filetypes it will use those, if not - anything is allowed.
[eluser]xwero[/eluser]
In the mimes config file you could do something like Code: $mimes = array( No hacks needed, you have to learn to love config files
[eluser]xwero[/eluser]
Oops i was wrong thinking it would be possible to add img to the mimes and it would all work out, i'm sorry. |
Welcome Guest, Not a member yet? Register Sign In |