I cannot load css file types in codeigniter

I am trying to load css user cignigniter download class. Here is the controller:

public function uploadcssfile() { $config['upload_path'] = './stylesheets/stores/'.$memberid.'/'; $config['file_name'] = 'main.css'; $config['allowed_types'] = 'css'; $config['overwrite'] = true; $this->load->library('upload', $config); if (! $this->upload->do_upload('filefieldname')) { die($this->upload->display_errors()); } } 

I just want to download a file like css, but codeigniter always gives this error:

 The filetype you are attempting to upload is not allowed. 
+8
css mime-types php file-upload codeigniter
source share
1 answer

I know this is really weird, but it worked for me:

in the application /config/mimes.php line 77

 'css' => 'text/css', 

change to:

 'css' => array('text/css','text/x-c'), 

To see if your development environment has its own sense of humor and can add new mime types to any text files (in my case), check your memes as follows:

 if ( ! $this->upload->do_upload(-your-form-input-name-) ){ print_r($_FILES['-your-form-input-name-']['type']); exit($this->upload->display_errors(). 'File Type: ' . $this->upload->file_type); } 

If the download fails, it will show you what type of mime your server is actually working with.

PS. Now that there is an answer to your question, go here and help me :)

+3
source share

All Articles