In this tutorial I will show you a easy and simple process to uploading profile picture size limit set, when you will uploading picture into the MySQL Database in Codeigniter.
In Codeigniter I will show you to upload image into MySQL database in the previous tutorial. Now I will help you to set image size limit in your Codeigniter Project at the uploading time of record. User whose use this framework and try to upload a profile picture into Database and in the Folder directory.
A user profile picture need minimum length of picture size, But when user upload picture using this framework then many times they are not fixed the image size. So they have faced many problems to show the profile picture in the view page or show the large picture in the page.
This tutorial I will give you the helping code that’s help you to set a limit of uploading profile picture. You can use the code any other image uploading times or insert file into the database. The example codes are below. Follow the example code
Example 1:
<?php $image =$_FILES['profile_image']['name']; $config['upload_path'] = './asset/images/'; $config['file_name'] = $image; $config['max_size'] = 750; $this->load->library('upload', $config); $data = array("profile_image"=>$image); $this->Model->profile_insert($data); ?>
Example 2:
There you can set the picture width and height size limit with picture size limit.
<?php $image =$_FILES['profile_image']['name']; $config['upload_path'] = './asset/images/'; $config['file_name'] = $image; $config['max_size'] = 1980; $config['max_width'] = 1240; $config['max_height'] = 1240; $this->load->library('upload', $config); $data = array("profile_image"=>$image); $this->Model->profile_insert($data); ?>
Example 3:
There you can set to allow the file types
<?php $image =$_FILES['profile_image']['name']; $config['upload_path'] = './asset/images/'; $config['allowed_types'] = 'gif|jpg|jpeg|png'; $config['file_name'] = $image; $config['max_size'] = 2480; $config['max_width'] = 1740; $config['max_height'] = 1340; $this->load->library('upload', $config); $data = array("profile_image"=>$image); $this->Model->profile_insert($data); ?>
The image size limit is help to save the project MB size or make your web server so fast. If you have a register page in your Project where user can register and uploads a profile picture there. So you want to set size limit for there is not much emphasis picture or document file in the Project.