这是我的代码,我不知道为什么它不工作我已经有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" />
答案 0 :(得分: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);
}
}
试试这个。至少你会发现那里发生了什么错误