dongya4089 2015-05-23 05:37
浏览 31

固定大小在codeigniter中上传图像

I want upload image with fixed size in codeigniter.But my code is not working.Anyone please help me for doing this..My code is

public function createevent() {

            if ($this->input->post('submit')) {

                $config['upload_path'] = './uploads/';
                $config['allowed_types'] = 'gif|jpg|png'; 
                $config['max_width'] = '366';       
                $config['max_height'] = '269';
                $this->load->library('upload', $config);


    //    $data = array('upload_data' => $this->upload->data());
                    $data = $this->upload->data();
                    $logo = $data['file_name'];  
          $fileInfo = getimagesize($data);

    if( $fileInfo['width'] == 366 && $fileInfo['height'] == 269 ) {
    //          if(($fileInfo[0] == 366) && ($fileInfo[1] == 269 )){
    //            if ($this->upload->do_upload()) {                         


                        $this->event_model->createevent( $logo);
                        $this->session->set_flashdata('msg', 'Event Created');

              }  else {
    //                    $this->image_lib->resize();
                        $this->session->set_flashdata('error', 'Please upload image within the size limit');
                        redirect('event/events');
                }
                }
            }
  • 写回答

1条回答 默认 最新

  • dongtuan1980 2015-05-23 17:00
    关注

    Please use $fileInfo['image_width'] & $fileInfo['image_height'] instead of

    $fileInfo['width'] & $fileInfo['height']

    This will work. :)

    评论

报告相同问题?

悬赏问题

  • ¥20 测距传感器数据手册i2c
  • ¥15 RPA正常跑,cmd输入cookies跑不出来
  • ¥15 求帮我调试一下freefem代码
  • ¥15 matlab代码解决,怎么运行
  • ¥15 R语言Rstudio突然无法启动
  • ¥15 关于#matlab#的问题:提取2个图像的变量作为另外一个图像像元的移动量,计算新的位置创建新的图像并提取第二个图像的变量到新的图像
  • ¥15 改算法,照着压缩包里边,参考其他代码封装的格式 写到main函数里
  • ¥15 用windows做服务的同志有吗
  • ¥60 求一个简单的网页(标签-安全|关键词-上传)
  • ¥35 lstm时间序列共享单车预测,loss值优化,参数优化算法