ユーザーがアップロードするときにファイル サイズを制限しようとしています。私は次の機能を持っています:
function do_upload()
{
$config['upload_path'] = './uploads/';
$config['allowed_types'] = 'gif|jpg|png|jpeg';
$config['max_size'] = '50';
//$config['max_width'] = '1024';
//$config['max_height'] = '768';
$this->load->library('upload', $config);
$fullImagePath;
if (isset($_FILES['userfile']) && !empty($_FILES['userfile']['name']))
{
if (! $this->upload->do_upload('userfile'))
{
$error = array('file_error' => $this->upload->display_errors());
//print_r($error);
$this->load->view('layout/header');
$this->load->view('register', $error);
$this->load->view('layout/footer');
}else{
// set a $_POST value for 'image' that we can use later
$upload_data = $this->upload->data();
$fullImagePath = '/uploads/' . $upload_data['file_name'];
}
}
//path of image on the server
return $fullImagePath;
}
上記の $error 配列を出力すると、ファイルが大きすぎるというエラーが表示されます。しかし問題は、印刷しなければ、写真が大きすぎてもプロセス全体が完了し、データベース内のデータが完成することです。どうすればこれを修正できますか?