用户
 找回密码
 入住 CI 中国社区
搜索
查看: 1785|回复: 1
收起左侧

CI上传提交路径报错

[复制链接]
发表于 2012-11-20 21:36:05 | 显示全部楼层 |阅读模式
我的控制器代码是这样的:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Upload extends CI_Controller
{
        function __construct()
        {
                parent::__construct();
                $this->load->helper(array('form', 'url'));
        }
        function index()
        {
                $this->load->view('upload_view');
        }
        function add()
        {
                //var_dump($_FILES['upfiles']);exit;
                $config['upload_path'] = "./upload/";
                $config['allowed_types'] = "gif|jpg|png";
                $config['max_size'] = "20000";
                $config['max_width'] = '1024';
                $config['max_height'] = '768';
                $this->load->library("upload", $config);
                if($this->upload->do_upload('upfiles'))
                {
                        $data = array('upload_data'=>$this->upload->data());
                        var_dump($data);
                }
                else
                {
                        $error = array('error'=>$this->upload->display_errors());
                        var_dump($error);
                }
        }
}

upload_model代码是这样的:
<html>
<form action="/index.php/upload/add" method="post" enctype="multipart/form-data">
<input type="file" name="upfiles" />
<input type="submit" name="sub" value="上传" />
</form>
</html>

然后点击上传后,总是报这样的错The requested URL /index.php/upload/add was not found on this server.

检查了很多遍提交路径没错啊,可不知道怎么的就是提交不过去,求高手指出到底是哪里出错了啊,折腾了半天也没解决,不知道是不是要配置什么东西的原因。。
发表于 2012-11-21 00:44:54 | 显示全部楼层
HTML复制代码
 
<form action="<?php echo base_url('index.php/upload/add'); ?>" method="post" enctype="multipart/form-data">
 
复制代码


若开启mod_rewrite 直接写 base_url('upload/add');

本版积分规则