Php 在Codeigniter中上载文件失败
这是我的代码,我不知道为什么它不工作,我已经有mimes.php的csv文件 我不知道怎么回事,我已经在其他函数中使用了这段代码,但在这里它不起作用 控制器:Php 在Codeigniter中上载文件失败,php,codeigniter,csv,upload,Php,Codeigniter,Csv,Upload,这是我的代码,我不知道为什么它不工作,我已经有mimes.php的csv文件 我不知道怎么回事,我已经在其他函数中使用了这段代码,但在这里它不起作用 控制器: function convert_csv(){ $config['upload_path'] = './files/contracts/'; $config['allowed_types'] = 'pdf|csv'; $c
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();
}
}
函数转换_csv(){
$config['upload_path']='./文件/合同/';
$config['allowed_types']='pdf | csv';
$config['max_size']='4096';
$this->load->library('upload',$config);
$this->upload->display_errors('','');
如果(!$this->upload->do_upload(“csvfile”)){
$error=array('error'=>this->upload->display_errors('','');
$this->session->set_flashdata(“上传消息”,$error);
}否则{
$upload_result=$this->upload->data();
}
}
视图:
选择要上载的文件:
试试这个。至少你会发现那里发生了什么错误你收到错误消息了吗?没有错误,但它没有上传,我总是重定向到我的基本url我真的不知道为什么它会重定向到基本url
<?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);
}
}