Делаю по аналогии с https://www.youtube.com/watch?v=YU6I-VKW39g Форма:
<form class="comment_form" data-request="onSubmit" data-request-files data-request-flash>
<input type="hidden" name="_handler" value="onSave">
{{ form_token() }}
{{ form_sessionkey() }}
...
<input type="file" name="commentimage" accept="image/*" data-request="onImageUpload" data-request-files data-request-flash>
</form>
Модель:
use System\Models\File;
class Comments extends Model
{
...
public $attachOne = [
'commentimage' => 'System\Models\File'
];
}
Загрузчик:
use System\Models\File;
use Input;
use Flash;
use Response;
class Comments extends ComponentBase
{
...
public function onImageUpload(){
$image = Input::all();
$file = (new File())->fromPost($image('commentimage'));// line 217
return [
'#imageResult' => 'img src="' . $file->getThumb(200,200,['mode'=>'crop']) . '">'
];
}
}
У меня выдаёт ошибку: "Function name must be a string" on line 217
Что не так?