I do by analogy with https://www.youtube.com/watch?v=YU6I-VKW39g Form:

<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> 

Model:

 use System\Models\File; class Comments extends Model { ... public $attachOne = [ 'commentimage' => 'System\Models\File' ]; } 

Loader:

 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']) . '">' ]; } } 

I get an error: "Function name must be a string" on line 217

What's wrong?

    1 answer 1

     $file = (new File())->fromPost($image['commentimage']); 

    That's right. For an array, square brackets are used.