我正在尝试上传css文件用户codigniter的上传类.这是控制器:
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()); } }
我只想上传一个css类型的文件,但codeigniter总是会出现这个错误:
The filetype you are attempting to upload is not allowed.
我知道,这真的很奇怪,但它对我有用:
在application / config / mimes.PHP中,第77行
'css' => 'text/css',
改成:
'css' => array('text/css','text/x-c'),
要看,如果您的开发环境有自己的幽默感并且可以为任何文本文件添加新的mime类型(我的情况),请检查您的mimes,如下所示:
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); }
PS.现在你的问题得到了答案,go here and help me 原文链接:https://www.f2er.com/php/137472.html