我正在尝试进行多个文件上传,其中一个input['file']
用于图像,另一个用于视频
这是控制器
public function upload(){
$data['errorPic'] = $this->validateUpload();
$data['errorVid'] = $this->validateUpload2();
}
public function validateUpload(){
if ( $_FILES AND isset($_FILES['coverImage']['name']) ){
$config['upload_path'] = 'blogpics/';
$config['allowed_types'] = 'png|gif|jpg|jpeg';
$config['max_size'] = '999999';
$this->load->library("upload",$config);
if(!$this->upload->do_upload("coverImage")){
return $this->upload->display_errors();
}
}
}
public function validateUpload2(){
if ( $_FILES AND isset($_FILES['video']['name'])){
$config['upload_path'] = 'blogvids/';
$config['allowed_types'] = 'png|gif|jpg|jpeg';
$config['max_size'] = '999999';
$this->load->library("upload",$config);
if(!$this->upload->do_upload("video")){
return $this->upload->display_errors();
}
}
}
只有第一个被调用的函数在工作
示例:如果我首先将validateUpload2()
函数放在函数顶部,则顶部的validateUpload()
第一个函数正在工作,第二个没有