使用Codeigniter和mysql上传视频

时间:2015-05-12 07:23:05

标签: php mysql codeigniter video

我尝试了很多方法通过我的网站上传视频。我不知道为什么,我可以保存图像,文本文件等,但无法将视频保存到文件夹和数据库中。

以下是我的观点。

<form action="<?php echo base_url();?>galleries/add_vdo" method="post" enctype="multipart/form-data">
                <div class="input-group">
                 <input type="text" class="form-control" placeholder="Enter Title" name="vdo_title" id="vdo_title"> 
                 <textarea class="form-control" placeholder="About Video"  name="vdo_desc" id="vdo_desc"></textarea>

                <input class="" name="ur_vdo" id="ur_vdo" type="file">

                <input class="btn btn-info" type="submit" name="submit" value="Add Now"/>
                <!--<button class="btn btn-info btn-lg" id="submit" type="button">Invite</button>-->

                </div>
                </form>  

控制器:

  function add_vdo()
  {
   $data['ur_vdo'] = $this->gallery_model->add_new_vdos(); 
   redirect('galleries/vdo_gal','refresh');
  }

型号:

 function add_new_vdos()
 {
 $this->load->helper('date');
 date_default_timezone_set('Asia/Calcutta');
 $config['upload_path'] = './uploads/myvideos/';
 $config['allowed_types'] = 'mp4|avi|flv|wmv|';                   

$this->load->library('upload', $config);
                    $this->upload->initialize($config);
                    $field_name ="ur_vdo";
                    $rgpic="0";
                    if ( !$this->upload->do_upload($field_name))
                    {
                    $error = $this->upload->display_errors();
                    $data['error']=$error;
                    }
                    else
                    {
                    $data = $this->upload->data();
                    $regpicname=$data['file_name'];
                    $rgpic="1";
                    }
                      if($rgpic!=0)
                   {

                    $dts = array(
                           'familypost_caption'=>$this->input->post('vdo_title'),
                           'familypost_desc'=>$this->input->post('vdo_title'),
                           'user_id' =>$uid,
                           'familypost_vdo'=>$regpicname,
                           'familypost_status'=>'A',
                           'familypost_date'=>now()
                           );
                   }
                   else
                   {
                    $dts = array(
                           'familypost_caption'=>$this->input->post('vdo_title'),
                           'familypost_desc'=>$this->input->post('vdo_title'),
                           'user_id' =>$uid,
                           'familypost_status'=>'A',
                           'familypost_date'=>now()
                           );
                        }   

                $vdqr = $this->db->insert('roottildb_familyposts',$dts);       
}

我不知道原因,视频上传失败但没有显示任何错误。我该如何解决这个问题?

0 个答案:

没有答案