CodeIgniter ライブラリの読み込みに問題があります。
私はすでに CodeIgniter を使って 3 つの Web サイトを構築しているので、このフレームワークには慣れていると思います。
問題はアップロードライブラリのみです。複数の関数で試しましたが、まだ機能しません。
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();
}