|
上传两个文件,一个视频,一个图片,怎么设在,能把两个文件放两个文件夹里?
这里边虽然两个方法都初始化了upload_path 但是第二个方法里的初始化没起到作用,怎么能让第二个初始化upload_path初始化成功?
public function get_video_info(){
$CI =& get_instance();
$file_sha = sha1_file($_FILES['video']['tmp_name']);
$config_v['upload_path'] = FCPATH . 'media/' ;
$config_v['allowed_types'] = 'gif|jpg|png|mp4';
$config_v['file_name'] = sha1_file($_FILES['video']['tmp_name']);
$CI->load->library('upload', $config_v);
if ( ! $CI->upload->do_upload('video')){
$data = array('error' => $CI->upload->display_errors());
if(isset($data['error'])){
return false;
}
}else{
$data = $CI->upload->data();
$this->upload_img();
}
return false;
}
public function upload_img(){
$CI =& get_instance();
$config_g['upload_path'] = FCPATH . substr($this->image_base_path,1) ;
$config_g['allowed_types'] = 'gif|jpg|png';
$config_g['file_name'] = sha1_file($_FILES['thumb']['tmp_name']);
$CI->load->library('upload', $config_g);
if ( ! $CI->upload->do_upload('thumb')){
$data = array('error' => $CI->upload->display_errors());
if(isset($data['error'])){
return false;
}
}else{
$data = $CI->upload->data();
var_dump($data);
return $this->image_base_path.$data['orig_name'];
}
}
|
|