我有一个上传图片和视频文件的表单。我在 php.ini
中设置了以下内容post_max_size = 10M
upload_max_filesize = 10M
现在的问题是,如果上传的视频文件不是允许的类型,它会完美地显示相应的错误。但是当我尝试上传更大尺寸(23MB)的视频时,它没有显示文件大小错误。下面给出了我上传视频和图像的控制器代码(我正在使用文件上传类)。
VideoController的代码:
function index()
{
$userid=$this->tank_auth->get_user_id();
if (empty($_FILES['thumb_image']['name']))
{
$this->form_validation->set_rules('thumb_image', 'Thumb Image', 'required|max_length[255]');
}
if (empty($_FILES['video']['name']))
{
$this->form_validation->set_rules('video', 'Video', 'required');
}
$this->form_validation->set_error_delimiters('<span class="error">', '</span>');
$data['page']='video/upload';
if ($this->form_validation->run() == FALSE) // validation hasn't been passed
{
$this->load->view('layout/template',$data);
}
else // passed validation proceed to post success logic
{
$file=$_FILES['video']['name'];
$thumbfile=$_FILES['thumb_image']['name'];
$form_data = array(
'videolink' => time().$file,
'videothumbnail' => time().$thumbfile,
'uploaderid' => $userid,
);
$config['upload_path'] = './secure/';
$config['allowed_types'] = 'mpeg|mp4|mpg|mpe|qt|mov|avi|movie|wmv|flv|3gp|mkv|dv|m4u|m4v|mxu|rv';
$config['max_size'] = '10240';
$extn = end(explode(".", $_FILES['video']['name']));
$config['file_name'] = time().$_FILES['video']['name'].'.'.$extn;
$this->load->library('upload', $config);
$this->upload->initialize($config);
$data['upload_data'] = '';
if (!$this->upload->do_upload('video'))
{
$data['msg'] = $this->upload->display_errors(); // this is not throwing error
$this->load->view('layout/template',$data);
}
else
{
$data['upload_data'] = $this->upload->data();
if($_FILES['thumb_image']['name']!="")
{
$config1['upload_path'] = './secure/';
$ext = end(explode(".", $_FILES['thumb_image']['name']));
$config1['file_name'] = time().$_FILES['thumb_image']['name'].'.'.$ext;
$config1['allowed_types'] = 'jpg|png|jpeg|gif|bmp|jpe|tiff|tif';
$this->load->library('upload', $config1);
$this->upload->initialize($config1);
if (!$this->upload->do_upload('thumb_image'))
{
$data['msg'] = $this->upload->display_errors();
$this->load->view('layout/template',$data);
}
}
if ($this->Video_model->SaveForm($form_data) == TRUE) // the information has therefore been successfully saved in the db
{
$this->session->set_flashdata('msgresult', 'Successfully uploaded the video !');
}
else
{
$this->session->set_flashdata('msgresult', 'Please try again. Some error occur during uploading.');
}
$data['errors'] = false;
$data['success'] = true;
redirect('video/upload');
}
}
}
有人可以帮我解决问题吗?
提前感谢您的帮助。
答案 0 :(得分:-1)
Jenz
请将以下代码放在index.php中,以免错误
<?php
error_reporting(E_ALL);
ini_set('display_errors',1);
?>