Home >Backend Development >PHP Tutorial >ci 框架,视频上传的问题
新学习ci框架,很多都不清楚,最近做一个文件上传的功能,遇到了些困难
//$id是本条文章的id号,意思是每个文件夹只能存放50条视频 public function addmove($id){ $uid = $this->session->userdata('id'); $a=(int)($id/50); $up_file_path=FILEPATH.'movies/'.$a; if(is_dir($up_file_path)){ $up_file_path=$up_file_path; } else { mkdir($up_file_path,0777); } $config['upload_path'] = $up_file_path; $config['allowed_types'] = 'mp4|avi'; $config['max_size'] = '1000000'; $this->load->library('upload', $config); $this->upload->do_upload("fileurl"); if(!$this->upload->do_upload('fileurl')) { $error = array('error' => $this->upload->display_errors()); } $data = $this->upload->data(); $strlen=strlen(FILEPATH); $movepath=substr($data['full_path'],$strlen); $data1 = array( 'fileurl' => '/media/'.$movepath, 'file_name' => $data['raw_name'] ); $this->db->where('id', $id); $this->db->update('content', $data1); }
2、windows可以下载此目录视频文件,linux上不能下载,提示404错误(文件找不到);
存放的目录是 /media/movies/1/我爱你.mp4
自己搞定,增加config.php里的mime类型。