2017-05-04 81 views
-2

查看修身图片剪裁用CodeIgniter

<form method="post" enctype='multipart/form-data' action="<?php base_url();?>edituserpic" name="form_editpic" id="form_editpic" class="avatar"> 

    <div class="slim" 
     data-label="Drop your avatar here" 
     data-size="240,240" 
     data-ratio="1:1"> 
     <input type="file" name="avatar" required /> 
    </div> 

    <button type="submit">Upload now!</button> 

</form> 

控制器

public function edit_user_pic() { 
    $data['baseurl'] = $this->config->item('base_url'); 

// Pass Slim's getImages the name of your file input, and since we only care about one image, postfix it with the first array key 
    $image = $this->slim->getImages('avatar')[0]; 

    */  
// Grab the ouput data (data modified after Slim has done its thing) 
    if (isset($image['output']['data'])) 
    { 
     // Original file name 
     $name = $image['output']['name']; 
     // Base64 of the image 
     $data = $image['output']['data']; 

    } 
} 

我只是停留在服务器端如何保存获得输出图像并保存到数据库中。

我得到$name未定义。这意味着输出是空的。

如果有人使用它,并能够帮助,那将是伟大的。

+0

还添加代码你试过。 –

+0

这里是插件:http://slimimagecropper.com –

回答

0

如果您已经设置为使用与"slim"不同的名称,请传递它。

$images = Slim::getImages('avatar'); 
$image = $images[0]; 

它适用于我。

+0

谢谢你,它也适用于我。 –

+0

@WikiBabu你也可以接受这个答案。 –