codeigniter上传文件重定向到未知链接

时间:2016-07-12 12:33:05

标签: php codeigniter upload

这是我的控制器

public function upload_file(){

    $this->load->helper('form');
    $this->load->helper('url');
    // set path to store uploaded files
    $config['upload_path'] = './uploads/';
    // set allowed file types
    $config['allowed_types'] = 'pdf';
    // set upload limit, set 0 for no limit
    //$config['max_size']    = 0;
    // load upload library with custom config settings
    $this->load->library('upload', $config);

    if($this->upload->do_upload()){
        $this->add_view();
    }else{
        print_r('x');
        exit();
    }
}

我的观点是

echo form_open_multipart('PDFuploads/upload');

问题是我不知道为什么它被重定向到这个链接

http://localhost/TLC_HR/PDFuploads/upload

3 个答案:

答案 0 :(得分:0)

在此处提供正确的控制器和操作

echo form_open_multipart('controller/action');

并且您将控制器操作称为 upload_file()

答案 1 :(得分:0)

$这 - > upload-> do_upload( 'userfile的')

缺少

userfile 。 input type =“file”name =“userfile”

答案 2 :(得分:0)

检查你的' base_url'在application / config / config.php中