Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I want to set minimum width and height for uploading images in codeigniter. The code is shown below.

$config['max_width']  = '480';
$config['max_height']  = '270';
$this->upload->do_upload()

I have set maximum cut off for this but how to set minimum ??

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
317 views
Welcome To Ask or Share your Answers For Others

1 Answer

Copy your Upload.php from system/libraries and paste on application/libraries. Then, introduce 2 new variables.

public $max_width               = 0;
public $max_height              = 0;
public $min_width               = 0; // new
public $min_height              = 0; // new

Add these to the initialize function so that you can pass values through a $config variable.

Locate is_allowed_dimensions function and modify it.

if ($this->min_width > 0 AND $D['0'] < $this->min_width)
{
    return FALSE;
}
if ($this->min_height > 0 AND $D['1'] < $this->min_height)
{
    return FALSE;
}

Check the upload language file and alter the upload_invalid_dimensions key accordingly to fit your case.

Have not tested this, but should work :)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...