简体   繁体   English

在codeigniter php中设置图像的宽度和高度不起作用

[英]setting width and height of image in codeigniter php not working

i have a codeigniter website where user can upload multiple images, i want all the images to be of the same size, i have done the following code in controller:我有一个 codeigniter 网站,用户可以上传多个图像,我希望所有图像的大小相同,我在控制器中完成了以下代码:

if (isset($_POST['addblog'])) {
    $this->load->library('upload');
    $image = array();
    $ImageCount = count($_FILES['image_name']['name']);

    for ($i = 0; $i < $ImageCount; $i++) {
        $_FILES['file']['name'] = $_FILES['image_name']['name'][$i];
        $_FILES['file']['type'] = $_FILES['image_name']['type'][$i];
        $_FILES['file']['tmp_name'] = $_FILES['image_name']['tmp_name'][$i];
        $_FILES['file']['error'] = $_FILES['image_name']['error'][$i];
        $_FILES['file']['size'] = $_FILES['image_name']['size'][$i];

        $uploadPath = './uploads/blog/';
        $config['upload_path'] = $uploadPath;
        $config['allowed_types'] = 'jpg|jpeg|png|gif';
        $config['width'] = 200;
        $config['height'] = 250;

        $this->load->library('upload', $config);
        $this->upload->initialize($config);

        if ($this->upload->do_upload('file')) {

            $imageData = $this->upload->data();

            $uploadImgData[] = $imageData['file_name'];
        }
    }
    $blogimage = $uploadImgData;
}

as u can see i have set the height and width in config, the images are still uploaded in ther original size, can anyone please tell me what is wrong in here, thanks in advance如您所见,我已在配置中设置了高度和宽度,图像仍以原始尺寸上传,谁能告诉我这里有什么问题,提前谢谢

You has just made a little mistake in your config :您刚刚在配置中犯了一个小错误:

$config['max_width'] = 200; 
$config['max_height'] = 250; 

Sadly "min_width" and "min_height" seems doesn't exist yet可悲的是“min_width”和“min_height”似乎还不存在

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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