1

这是我的代码,我不知道为什么它不起作用我已经有 csv 文件的 mimes.php 我不知道出了什么问题我已经在其他功能中使用了此代码,但在这里它不起作用。

控制器:

    function convert_csv(){

                $config['upload_path']   = './files/contracts/'; 
                $config['allowed_types'] = 'pdf|csv';   
                $config['max_size']      = '4096';      

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

                if ( !$this->upload->do_upload("csvfile")){
                    $error = array('error' => $this->upload->display_errors('<span>','</span>'));
                    $this->session->set_flashdata("upload_message", $error);
                } else{
                    $upload_result = $this->upload->data(); 
                }   
}

看法:

<?php   $form_options = array( 'id'    => 'contract_items', 
                               'class' => 'form-horizontal' ); ?>

<?=$this->formbuilder->open( $controller.'/convert_csv/'.$c->id, TRUE, $form_options );?>
    <?php echo form_open_multipart('upload/do_upload');?>

        Select File To Upload:<br />
        <input type="file" name="csvfile" value="csvfile" text="csvfile" />
          <br /><br />
        <input type="submit" value="Submit" />
4

1 回答 1

0
    function convert_csv(){

            $config['upload_path']   = './files/contracts/'; 
            $config['allowed_types'] = 'pdf|csv';   
            $config['max_size']      = '4096';      

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

            if ( !$this->upload->do_upload("csvfile")){
               echo $this->upload->display_errors();

            } else{
                $upload_result = $this->upload->data(); 
              var_dump($upload_result);
            }   
}

尝试这个。至少你会发现那里发生了什么错误

于 2013-11-22T08:47:01.340 回答