<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
が未定義です。この平均出力は空です。
誰もがそれを使用し、それが偉大になるのを助けることができる場合。
また、試したコードを追加してください。 –
ここにプラグインがあります:http://slimimagecropper.com –