2017-05-04 4 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この回答も受け入れることができます。 –

関連する問題