Need help for upload from another controller


i appreciate it if anyone could help me
i used Josegonzalez once to upload images in one of my controllers and it works. now i want to upload image from another controller add action too. therefore i used the following code in my model

$this->addBehavior(‘Josegonzalez/Upload.Upload’, [
// You can configure as many upload fields as possible,
// where the pattern is field => config
// Keep in mind that while this plugin does not have any limits in terms of
// number of files uploaded per request, you should keep this down in order
// to decrease the ability of your users to block other requests.
‘photo4’ => [
‘fields’ => [
‘dir’ => ‘photo4_dir’,
‘size’ => ‘photo4_size’,
‘type’ => ‘photo4_type’
‘nameCallback’ => function ($data, $settings) {
return strtolower($data[‘name’]);
‘transformer’ => function ($table, $entity, $data, $field, $settings) {
$extension = pathinfo($data[‘name’], PATHINFO_EXTENSION);

                // Store the thumbnail in a temporary file
                $tmp = tempnam(sys_get_temp_dir(), 'upload') . '.' . $extension;

                // Use the Imagine library to DO THE THING
                $size = new \Imagine\Image\Box(40, 40);
                $mode = \Imagine\Image\ImageInterface::THUMBNAIL_INSET;
                $imagine = new \Imagine\Gd\Imagine();

                // Save that modified file to our temp file
                    ->thumbnail($size, $mode)

                // Now return the original *and* the thumbnail
                return [
                    $data['tmp_name'] => $data['name'],
                    $tmp => 'thumbnail-' . $data['name'],
            'deleteCallback' => function ($path, $entity, $field, $settings) {
                // When deleting the entity, both the original and the thumbnail will be removed
                // when keepFilesOnDelete is set to false
                return [
                    $path . $entity->{$field},
                    $path . 'thumbnail-' . $entity->{$field}
            'keepFilesOnDelete' => false

it’s the same as in the other controller but not saving the image in this table through this controller.
i don’t know what to do