这是我的代码:
config['upload_path'] = './media/resumes/';
$config['allowed_types'] = 'pdf|doc|docx';
$config['max_size'] = '100000';
$this->load->library('upload', $config);
$this->upload->do_upload("myfile");
// enabling this code will result in duplication of uploaded file
$file = $this->upload->data();
$filename=$file['file_name'];
问题是,我尝试.jpg
甚至.php
,文件已成功上传!没错!
为什么会这样,我该如何解决?
答案 0 :(得分:1)
代码中没有任何错误,添加此行$this->upload->display_errors();
并检查其工作
$config['upload_path'] = './media/resumes/';
$config['allowed_types'] = 'pdf|doc|docx';
$config['max_size'] = '100000';
$this->load->library('upload', $config);
$this->upload->do_upload("myfile");
$this->upload->display_errors(); //add this line too
$file = $this->upload->data();
$filename = $file['file_name'];
答案 1 :(得分:0)
$this->load->library('upload', $config);
此后尝试添加
$this->upload->initialize($config);
可能会帮助你。
答案 2 :(得分:0)
also_works
尝试这种情况应该有效..