src/FormField/Upload.php
public function onUpload($fx = null)
    {
        if (is_callable($fx)) {
            $this->hasUploadCb = true;
            if ($this->cb->triggered()) {
                $action = @$_POST['action'];
                if ($files = @$_FILES) {
                    //set fileId to file name as default.
                    $this->fileId = $files['file']['name'];
                    // display file name to user as default.
                    $this->setInput($this->fileId);
                }
                if ($action === 'upload' && !$files['file']['error']) {
                    $this->cb->set(function () use ($fx, $files) {
                        $this->addJsAction(call_user_func_array($fx, $files));
                        //$value = $this->field ? $this->field->get() : $this->content;
                        $this->addJsAction([
                            $this->js()->atkFileUpload('updateField', [$this->fileId, $this->getInputValue()]),
                        ]);

                        return $this->jsActions;
                    });
                } elseif ($action === null || isset($files['file']['error'])) {
                    $this->cb->set(function () use ($fx, $files) {
                        return call_user_func($fx, 'error');
                    });
                }
            }
        }
    }
public function onUpload($fx = null)
    {
        if (is_callable($fx)) {
            $this->hasUploadCb = true;
            if ($this->cb->triggered()) {
                $action = @$_POST['action'];
                if ($files = @$_FILES) {
                    //set fileId to file name as default.
                    $this->fileId = $files['file']['name'];
                    // display file name to user as default.
                    $this->setInput($this->fileId);
                }
                if ($action === 'upload' && !$files['file']['error']) {
                    $this->cb->set(function () use ($fx, $files) {
                        $this->addJsAction(call_user_func_array($fx, $files));
                        //$value = $this->field ? $this->field->get() : $this->content;
                        $this->addJsAction([
                            $this->js()->atkFileUpload('updateField', [$this->fileId, $this->getInputValue()]),
                        ]);

                        return $this->jsActions;
                    });
                } elseif ($action === null || isset($files['file']['error'])) {
                    $this->cb->set(function () use ($fx, $files) {
                        return call_user_func($fx, 'error');
                    });
                }
            }
        }
    }
public function onUpload ( $ fx = null ) { if ( is_callable ( $ fx ) ) { $ this -> hasUploadCb = true ; if ( $ this -> cb -> triggered ( ) ) { $ action = @ $ _POST [ 'action' ] ; if ( $ files = @ $ _FILES ) { //set fileId to file name as default. $ this -> fileId = $ files [ 'file' ] [ 'name' ] ; // display file name to user as default. $ this -> setInput ( $ this -> fileId ) ; } if ( $ action === 'upload' && ! $ files [ 'file' ] [ 'error' ] ) { $ this -> cb -> set ( function ( ) use ( $ fx , $ files ) { $ this -> addJsAction ( call_user_func_array ( $ fx , $ files ) ) ; //$value = $this->field ? $this->field->get() : $this->content; $ this -> addJsAction ( [ $ this -> js ( ) -> atkFileUpload ( 'updateField' , [ $ this -> fileId , $ this -> getInputValue ( ) ] ) , ] ) ; return $ this -> jsActions ; } ) ; } elseif ( $ action === null || isset ( $ files [ 'file' ] [ 'error' ] ) ) { $ this -> cb -> set ( function ( ) use ( $ fx , $ files ) { return call_user_func ( $ fx , 'error' ) ; } ) ; } } } }
onUpload callback.
Call when user is uploading a file.

@param callable $fx
onUpload callback . Call when user is uploading a file .