简体   繁体   English

在Codeigniter中上传文件失败

[英]Uploading File failed in Codeigniter

Here is my code and i dont know why its not working i already have mimes.php of csv file I don't know what is wrong i already use this code in other function its working but in here it's not working. 这是我的代码,我不知道为什么它不起作用,我已经有csv文件的mimes.php我不知道是什么问题,我已经在其他功能中使用了此代码,但是在这里它不起作用。

Controller: 控制器:

    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(); 
                }   
}

View: 视图:

<?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" />
    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);
            }   
}

Try this. 尝试这个。 At least you'll find what error going on there 至少您会发现那里发生了什么错误

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM