上传docx时,pdf文件,不允许使用您尝试上传的文件类型。 我的添加函数是:-
public function add() {
$this->load->helper('ckeditor'); // for loading ckeditor
$this->load->library('form_validation');
$this->form_validation->set_rules($this->validation_rules);
if ($this->form_validation->run() == TRUE) {
$file_name = '';
if ($_FILES["file"]["size"] > 0) {
$this->load->library('upload', $this->fu_config);
if (!$this->upload->do_upload('file')) {
$this->session->set_flashdata('error', $this->upload->display_errors());
redirect('files/add', 'refresh');
} else {
$file = $this->upload->data();
$file_name = $file['file_name'];
}
}
// preparing for insertion
foreach ($this->validation_rules as $k => $v) {
$fields[] = $v['field'];
}
$data = $this->files_model->array_from_post($fields);
$data['file'] = $file_name;
if ($this->files_model->save($data)) {
$this->session->set_flashdata('success', 'New Event Added Successfully.');
} else {
$this->session->set_flashdata('error', 'sorry, Event cannot be Added.');
}
redirect('files/add/', 'refresh');
} else {
$files = new stdClass();
// Go through all the known fields and get the post values
foreach ($this->validation_rules as $key => $field) {
$files->$field['field'] = set_value($field['field']);
}
}
$data = array(
'method' => 'add',
'main_content' => 'form',
'editData' => $files,
'ckeditor' => array(
'id' => 'description',
'path' => 'js/ckeditor',
)
);
$this->load->view('admin_wrapper', $data);
}
我尝试更改系统/库/上传.php第 199 行:
$this->_file_mime_type($_FILES[$field](; 将该行更改为:
$this->_file_mime_type($_FILES[$field](; var_dump($this->file_type(; 死亡((;
我出去放这个: -
字符串(42( "无法打开 '' (没有这样的文件或目录(">
我该如何解决此错误?
请确保您的$this->fu_config
正确, 配置示例:
$config['upload_path'] = './uploads/'; //Your file path for upload
$config['allowed_types'] = 'pdf|docx';
$config['max_size'] = 100;
$config['max_width'] = 1024;
$config['max_height'] = 768;