我在加载 CodeIgniter 库时遇到问题,
我已经使用 CodeIgniter 构建了三 (3) 个网站,所以我认为自己熟悉这个框架。
问题仅在于上传库。我已经尝试了多种功能,但它仍然无法正常工作。
我什至尝试过CodeIgniter 示例
在谷歌我找不到任何答案,有人知道它可能是什么吗?
class Admin extends CI_Controller {
public function __construct(){
parent::__construct();
$this->load->library('session');
$this->load->library('v');
$this->load->model('admin_model');
}
public function upload_a_thing($set = null){
$this->load->helper(array('form', 'url'));
if(!$set){
$this->load->view('admin/upload_a_thing');
}else{
$this->load->library('Upload');
if (!$this->upload->do_upload('userfile')){
echo $this->upload->display_errors();
} else {
$file = $this->upload->data();
// $product = $this->admin_model->get_products($id);
$newFilePath = $config['upload_path'].'try.jpg';
$file['file_name'] = str_replace(" ","_",$file['file_name']);
rename($config['upload_path'].$file['file_name'], $newFilePath);
}
}
}
CodeIgniter 错误
Undefined property: Admin::$upload
PHP 错误
Fatal error: Call to a member function do_upload() on a non-object
为 Spary 编辑
$config['upload_path'] = './media/imgs/products/';
$this->load->library('upload',$config);
if (!$this->upload->do_upload('userfile')){
echo $this->upload->display_errors();
}