2017-05-04 87 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你也可以接受這個答案。 –