public function actionUpload($model, $primaryKey)
 {
     $results = [];
     $modelImage = new Image();
     $modelImage->model = $model;
     $modelImage->primaryKey = $primaryKey;
     $filePath = $modelImage->getFilePath();
     if (Yii::$app->request->isPost) {
         $modelImage->file = UploadedFile::getInstance($modelImage, 'file');
         if ($modelImage->file && $modelImage->validate()) {
             $filename = $modelImage->file->name;
             $modelImage->src = $filename;
             $modelImage->position = $modelImage->nextPosition;
             $modelImage->save();
             if ($modelImage->file->size > 1024 * 1024) {
                 Image::thumb($modelImage->file->tempName, $filePath . '/' . $filename, '2592x1728');
             } else {
                 $modelImage->file->saveAs($filePath . '/' . $filename);
             }
             $imagePath = $filePath . '/' . $filename;
             $result = ['name' => $filename, 'size' => filesize($filePath . '/' . $filename), 'url' => $imagePath, 'thumbnailUrl' => $modelImage->resize('100x100'), 'deleteUrl' => Url::to(['/core/image/delete', 'id' => $modelImage->id]), 'deleteType' => "DELETE"];
             $results[] = $result;
         } else {
             $results[] = (object) [$modelImage->file->name => false, 'error' => strip_tags(Html::error($modelImage, 'file')), 'extension' => $modelImage->file->extension, 'type' => $modelImage->file->type];
         }
     }
     echo json_encode((object) ['files' => $results]);
 }