用户
 找回密码
 入住 CI 中国社区
搜索
查看: 3544|回复: 8
收起左侧

[已解决] image_lib的resize()的問題

[复制链接]
发表于 2011-1-18 18:53:46 | 显示全部楼层 |阅读模式
本帖最后由 wssx 于 2011-1-20 16:19 编辑

用的是swf的上傳,現在出現有的圖片能上傳,有的不能上傳,經測試發現$this->load->library('image_lib',$config);執行到這一句正常,$this->image_lib->resize()執行到這一句的時候有問題,
PHP复制代码
 
if (!$this->image_lib->resize())
    {
        $_SESSION['reg'] = 'ffff';
    }else{
        $_SESSION['reg'] = 'ggg';
    }
 
复制代码

發現無論如何session的值寫入不進去。請大家幫忙看看是啥問題。
发表于 2011-1-19 13:05:11 | 显示全部楼层
贴代码。
 楼主| 发表于 2011-1-19 13:26:01 | 显示全部楼层
PHP复制代码
 
        //壓成大圖
                                                $upload_file['b_filename'] = $save_info['path'].'/b_'.$upload_file['name'];
                                                $config = array(
                                                        'image_library' => 'gd2',
                                                        'source_image' => $upload_file['filename'],
                                                        'maintain_ratio' => true,
                                                        'width' => 1024,
                                                        'height'=> 3000,
                                                        'new_image'=> $upload_file['b_filename']
                                                );
                                               
                                                $this->load->library('image_lib',$config);
                                               
                                                if (!$this->image_lib->resize())
                                                {
                                                        $_SESSION['reg'] = 'ffff';
                                                }else{
                                                        $_SESSION['reg'] = 'ggg';
                                                }
                                                $this->image_lib->resize();
                                        //      $_SESSION['reg'] = 'eeeee';
                                                $this->image_lib->clear();
                                               
                                                //壓成中圖
                                                $config = array(
                                                        'image_library' => 'gd2',
                                                        'source_image' => $upload_file['b_filename'],
                                                        'maintain_ratio' => true,
                                                        'width' => 80,
                                                        'height'=> 80,
                                                        'new_image'=> $upload_file['filename']
                                                );
                                                $this->image_lib->initialize($config);
                                                $this->image_lib->resize();
                                                $this->image_lib->clear();
                                               
                                                //壓成小圖
                                                $upload_file['s_filename'] = $save_info['path'].'/s_'.$upload_file['name'];
                                                $config = array(
                                                        'image_library' => 'gd2',
                                                        'source_image' => $upload_file['filename'],
                                                        'maintain_ratio' => true,
                                                        'width' => 28,
                                                        'height'=> 28,
                                                        'new_image'=> $upload_file['s_filename']
                                                );
                                                $this->image_lib->initialize($config);
                                                $this->image_lib->resize();
                                                $this->image_lib->clear();
 
复制代码

代碼如上,很多圖片在$this->image_lib->resize();執行到這裡的時候就死了。
发表于 2011-1-19 15:07:58 | 显示全部楼层
看起来没什么问题 -_-
有什么报错吗?
 楼主| 发表于 2011-1-19 16:18:38 | 显示全部楼层
回复 4# Hex


   
PHP复制代码
 
if (!$this->image_lib->resize())
{
   $_SESSION['reg'] = 'ffff';
}else{
       $_SESSION['reg'] = 'ggg';
  }
 
复制代码

這個session的值一直是空的。這個讓我感覺很不理解!
 楼主| 发表于 2011-1-19 16:19:58 | 显示全部楼层
如果不加$this->image_lib->resize()這句什麽圖片都能上傳成功,加上之後有的圖片就上傳不了,而且不能上傳的圖片也沒有規律可循
发表于 2011-1-19 17:32:14 | 显示全部楼层
目前说不好是什么造成的,可能和你的服务器环境有关。
 楼主| 发表于 2011-1-19 18:21:16 | 显示全部楼层
現在加了個圖片尺寸的判斷,發現昨天不能上傳的圖片可以上傳了。而且進的的代碼是帖子中貼的的代碼,實在是無語了。
 楼主| 发表于 2011-1-19 18:22:16 | 显示全部楼层
肯定不是服務器的問題,現在我這個案子上傳圖片的模塊有6個,就發現這一個有問題。

本版积分规则