首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >codeigniter照片thumb创建和上传

codeigniter照片thumb创建和上传
EN

Stack Overflow用户
提问于 2009-07-23 14:15:09
回答 3查看 5.9K关注 0票数 2

它给出了空白屏幕:/它上传了第一张图片,这很好。然后调用_create_thumbnail并在"$this->image_lib->resize()“行显示空白屏幕:/

你知道问题出在哪里吗?

谢谢!!

上传照片* ================================================================== * /** *

* Thumb = 210px - 160px * Original = 500px - 385px * */

代码语言:javascript
复制
function img_upload() 
{
    $config['upload_path'] = 'uploads/';
    $config['allowed_types'] = 'gif|jpg|jpeg|png';
    $config['max_size'] = '1000';
    $config['max_width'] = '1920';
    $config['max_height'] = '1280';     
    $config['width'] = 500;
    $config['height'] = 385;                

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

    if(!$this->upload->do_upload()) echo $this->upload->display_errors();
    else {

        $fInfo = $this->upload->data();
        $this->_create_thumbnail($fInfo['file_name']);

        $data['uploadInfo'] = $fInfo;
        $data['thumbnail_name'] = $fInfo['raw_name'] . '_thumb' . $fInfo['file_ext'];

        // set view
        $this->load->view('upload_success', $data); 
    }
}

function _create_thumbnail($fileName) 
{
    $config['image_library'] = 'gd2';
    $config['source_image'] = 'uploads/' . $fileName;   
    $config['create_thumb'] = TRUE;
    $config['maintain_ratio'] = TRUE;
    $config['width'] = 210;
    $config['height'] = 160;

    $this->load->library('image_lib', $config);
    if(!$this->image_lib->resize()) echo $this->image_lib->display_errors();

}
EN

回答 3

Stack Overflow用户

发布于 2009-07-24 16:46:37

在这里检查你的花括号:

if(!$this->upload->do_upload()) echo $this->upload->display_errors(); else {

看起来你混合了语法风格。

票数 1
EN

Stack Overflow用户

发布于 2010-03-31 16:13:29

尝试删除$fileName

而不是这个:$config['source_image'] = 'uploads/' . $fileName;

使用这个:$config['source_image'] = 'uploads/'

票数 0
EN

Stack Overflow用户

发布于 2011-04-12 18:21:10

尝尝这个

代码语言:javascript
复制
function _create_thumbnail($fileName) 
 {
$this->load->library('image_lib');
         $config['image_library'] = 'gd2';
         $config['source_image'] = './uploads/' . $fileName;       
         $config['create_thumb'] = TRUE;
         $config['maintain_ratio'] = TRUE;
         $config['width'] = 210;
         $config['height'] = 160;
         $config['new_image'] = './uploads/'.$fileName;

         $this->image_lib->initialize($config);
         if(!$this->image_lib->resize()) echo
 $this->image_lib->display_errors();

 }
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/1172066

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档