Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/codeigniter/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php Codeigniter文件上载错误_Php_Codeigniter - Fatal编程技术网

Php Codeigniter文件上载错误

Php Codeigniter文件上载错误,php,codeigniter,Php,Codeigniter,我正在开发一个投标管理系统,并试图在投标创建期间附上pdf文件 我有以下的控制器和视图,它显示了一些类似于没有选择文件的排序。我快死了 function addtender() { $this->form->set_rules('name', 'Tender Name', 'required|min_length[4]'); $this->form->set_rules('district', 'District Name', 'required|min_

我正在开发一个投标管理系统,并试图在投标创建期间附上pdf文件

我有以下的控制器和视图,它显示了一些类似于没有选择文件的排序。我快死了

function addtender() {
    $this->form->set_rules('name', 'Tender Name', 'required|min_length[4]');
    $this->form->set_rules('district', 'District Name', 'required|min_length[4]');
    $this->form->set_rules('department', 'Department Name', 'required|min_length[4]');
    $this->form->set_rules('userfile', 'Pdf File ', 'required');
    if($this->form->run()) {
    $config['upload_path'] = './assets/pdf/';
    $config['allowed_types'] = 'pdf';
    $config['max_size']    = 1000;
    $this->load->library('upload', $config);
    if (!$this->upload->do_upload('userfile'))
    {
        print_r($this->upload->display_errors());
         $this->data['page_data'] = 'admin/upload_view';
     }
    else
    {
          print_r($this->upload->data());
    }
    }
}
我有这个控制器代码上传pdf文件codeignitor。 我的观点是

    <div class="col-md-10">
<h3>Add Tenders</h3>
    <?=validation_errors('<div class="alert alert-danger">', '</div>');?>
    <?=form_open(site_url('admin/addtender'))?>
    <label>Tender Name</label>
    <input class="form-control" name="name" type="text">
    <label>District</label>
    <input type="text" name="district" class="form-control">
    <label>Department</label>
    <input type="text" name="department" class="form-control">
    <label>PDF file</label>
    <input type="file" name="userfile" class="form-control">
    <br>
    <input name="submit" type="submit" class="btn btn-primary" value="Add Tender">
</div>

添加投标书

你必须使表单多部分/表单数据

试试这个

<form enctype="multipart/form-data">
</form>

将文件上传代码放入表单中