0

Codeigniter のライブラリ内でヘルパーを呼び出すにはどうすればよいですか?

私のコード:

class Upload
{
    protected $ci;  

    function __construct()
    {   
        $this->ci =& get_instance();    

        // Load helper
        $this->ci->load->helper('form');
    }


    function upload_file($file, $file_types = 'gif|jpg|png', $max_size = 1000, $max_width = 200, $max_height = 300)
    {
        // Set params
        $config['upload_path'] = 'attached-files';
        $config['allowed_types'] = $file_types;
        $config['max_size'] = $max_size;

        // Check if max_width is set equals to it is a image
        if(isset($max_width))
        {
            $config['max_width']    = $max_width;
            $config['max_height']   = $max_height;  
        }

        // Try to upload the file
        if (!$this->ci->upload->do_upload($file))
        {
            $data['profile_image_upload'] = array('error' => $this->ci->upload->display_errors());
        }
        else
        {
            $data['upload_data'] = $this->ci->upload->data();
        }

        return $data;
    }

ファイルをアップロードしたいときに呼び出すユニバーサルライブラリを構築しようとしています.pdf、画像、または別のファイルの場合は独立しています。

しかし、次のコードでエラーが発生します。

if (!$this->ci->upload->do_upload($file))

エラー メッセージ: 未定義のメソッド Upload::do_upload() の呼び出し

4

1 に答える 1