gpt4 book ai didi

php - 在 Codeigniter 中超过最大文件大小时不显示错误消息

转载 作者:行者123 更新时间:2023-12-01 14:59:36 25 4
gpt4 key购买 nike

我有一个可以上传图片和视频文件的表单。我在 php.ini

中设置了以下内容
post_max_size = 10M
upload_max_filesize = 10M

现在的问题是,如果上传的视频文件不是允许的类型,它会完美显示相应的错误。但是当我尝试上传更大尺寸 (23MB) 的视频时,它没有显示文件大小错误。下面给出的是我上传视频和图像的 Controller 代码(我正在使用文件上传类)。

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');
}
}
}

谁能帮我解决这个问题?

在此先感谢您的帮助。

最佳答案

珍妮

请将下面的代码放在 index.php 中,这样你就可以得到错误

<?php 
error_reporting(E_ALL);
ini_set('display_errors',1);
?>

关于php - 在 Codeigniter 中超过最大文件大小时不显示错误消息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22602884/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com