简体   繁体   中英

Codeigniter upload library to validate min width and min height of image

I am using upload library in codeigniter to upload image….....

$config[‘allowed_types’]    = ‘gif|png|jpg’;
$config[‘max_size’]      = ‘1000’;
$config[‘max_width’]      = ‘200’;
$config[‘max_heigth’]      = ‘200’;
$config[‘upload_path’]    = ‘./uploads/’
$this->load->library(‘upload’, $config);

while user uploading image….....user should upload minimum widht and minimum height

for this how to do…......

CI have only max_width and max_heigth…...... I am aware about this function as well

 getimagesize();

but to use this function we need source image url... which i dont have access to...

To do this use next piece of code:

$data = $this->upload->data();
list($width, $height) = getimagesize($data['full_path']);

You should use JavaScript to determine the file's size before it gets uploaded, because PHP can't do it as it is server side rather than client.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM