codeigniter您没有选择要上传的文件

I have a codeigniter project that I am trying to upload a file too. When I submit the form I get back a data array of

Array ( [file_name] => [file_type] => [file_path] => ./uploads/ [full_path] => ./uploads/ [raw_name] => [orig_name] => [client_name] => [file_ext] => [file_size] => [is_image] => [image_width] => [image_height] => [image_type] => [image_size_str] => )

Even when I put a file in the input field.

Index.php

<?php $this->load->view('include/document_header'); ?>

<script src="<?php echo base_url(); ?>assets/script/fancybox/jquery.fancybox.pack.js"></script>
<link rel="stylesheet" type="text/css" href="<?php echo base_url(); ?>assets/script/fancybox/jquery.fancybox.css" />

<script src="<?php echo base_url(); ?>assets/script/jquery.filters.js"></script>
<link rel="stylesheet" type="text/css" href="<?php echo base_url(); ?>assets/style/jquery.filters.css" />

<script src="<?php echo base_url(); ?>assets/script/jquery.json-2.4.js"></script>

<script>
var FILTER_NAMES = <?php echo json_encode($this->filter_model->get_filter_names()); ?>;
</script>

<script src="<?php echo base_url(); ?>assets/script/export.js"></script>

<?php $this->load->view('include/site_header'); ?>

<div id="content" class="gradient gray">
    <h1 class="header">Import Contacts</h3>
        <form id="import_form" action="<?php echo $import_url; ?>" method="post" target="_blank">
            <h2 class="header">Copy CSV</h2>
            <fieldset id="fields">
                <div class="clearfix">
                    <label class="field">
                        <textarea name="copycsv" rows="4" cols="50"></textarea>
                    </label>
                </div>
            </fieldset>
            <h2 class="header">Upload CSV</h3>
            <fieldset id="fields">
                <div class="clearfix">
                    <label class="field">
                        <input type="file" name="userfile" size="20" />
                    </label>
                </div>
            </fieldset>
            <fieldset class="buttons clearfix">
                <input type="submit" name="submit" value="Submit" class="button gradient new_blue" />
            </fieldset>
        </form>
        <div class="helper">
            Download template CSV file. <a href="">Click here</a>
        </div>

</div>

<?php $this->load->view('include/site_footer'); ?>

import.php controller

<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
require FCPATH.'vendor/autoload.php';
use Goodby\CSV\Import\Standard\Lexer;
use Goodby\CSV\Import\Standard\Interpreter;
use Goodby\CSV\Import\Standard\LexerConfig;

class Import extends MY_Controller
{


    function __construct()
    {
        // Call the parent constructor
        parent::__construct();

        if(!has_tab_access('import'))
        {
            redirect_tabs('import');
        }
    }

    public function index()
    {
        $data = array(
            'import_url' => site_url(array('import', 'process'))
        );

        // Load the form view
        $this->load->view('import/index', $data);
    }

    public function process()
    {

        $fields = $this->input->post();
        var_dump($this->input->post());
        $config['upload_path'] = './uploads/';
        $config['allowed_types'] = 'text/comma-separated-values|application/csv|application/excel|application/vnd.ms-excel|application/vnd.msexcel|text/anytext';
        $config['max_size'] = '1000';

        $this->load->library('upload');
        $this->upload->initialize($config); 

        if (!$this->upload->do_upload('userfile')){
            echo $this->upload->display_errors();
            print_r($this->upload->data());
        }else{

        }

        #check to make sure fields are entered. If none of them have content 
        #error message displayed
        /*if(strlen($fields['copycsv'])  == 0 || strlen($fields['userfile']) == 0){
            #$this->load->view('import/index', $data);
            $this->load->library('user_agent');
            redirect($this->agent->referrer(), 'refresh');
        }else{
            if(strlen($fields['copycsv']) > 0 && strlen($fields['userfile']) == 0){

            }else if(strlen($fields['userfile']) > 0 && strlen($fields['copycsv']) == 0){

            }else{

            }
        }*/

    }

}

/* End of file import.php */
/* Location: ./application/controllers/import.php */

Not really sure what is going on.

Try using form open multipart. Form upload needs the form type to be multipart. It is best to do this with the form helper:

<?php echo form_open_multipart('controller/method');?>

In your case copying your info something like:

<?php echo form_open_multipart($import_url, array('id'=>'import_form', 'target'=>'_blank'));?>

Which you can see in the docs here: https://www.codeigniter.com/user_guide/libraries/file_uploading.html#creating-the-upload-form