Php 找不到对象。。控制器找不到该函数
这是我的控制器Php 找不到对象。。控制器找不到该函数,php,codeigniter,Php,Codeigniter,这是我的控制器 <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); class Admin extends CI_Controller { public function __construct() { parent::__construct(); $this->load->helper('url'); $t
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Admin extends CI_Controller {
public function __construct()
{
parent::__construct();
$this->load->helper('url');
$this->load->Model('Mod_admin');
}
public function index()
{
$this->load->helper(array('form')); //login purposes
$this->load->view('template/header');
$data['branches'] = $this->Mod_admin->getAllBranches();
$this->load->view('index',$data);
}
public function account()
{
$this->load->view('account', array('error' => ' ' ));
}
public function do_upload()
{
$config['upload_path'] = './uploads/';
$config['allowed_types'] = 'gif|jpg|png';
$this->load->library('upload', $config);
if ( ! $this->upload->do_upload())
{
$error = array('error'=>$this->upload->display_errors());
$this->load->view('account', $error);
}
else
{
$data=array('upload_data'=>$this->upload->data());
$this->load->view('success', $data);
}
}
}//last curly
这是位于视图中的MY ACCOUNT.PHP
<html>
<body>
<?php echo form_open_multipart('http://localhost/do_upload');?>
<input type="file" name="userfile" />
<br /><br />
<input type="submit" value="upload" />
</form>
</body>
</html>
当我上传一个文件时,它会重定向到一个页面,上面写着“找不到对象”。。我想我在链接上有问题。。请帮帮我。。对不起,我的语法不好您试图通过web浏览器访问什么功能?您似乎试图直接访问“do_upload”操作,尽管可以访问它,因为admin是控制器名称,CI将创建相同的对象。我已经尝试过,但它不起作用。。它仍然说object not Found当使用form_helper函数时,您不需要提供主机名,如下所示form_open“controller/method”我将路由更改为“admin/do_upload”,但当我上载图像时,它只在索引页中重定向我,而不上载任何内容。。我还尝试将该函数分离到另一个控制器,并将其命名为upload.php。我的路径是“upload/do_upload”,当我上传图像时,会弹出404页面not found