示例#1
0
 public function run()
 {
     /** @var Model | FileSaveBehavior $model */
     $model = new $this->model_class();
     $model->attachBehavior('file-save', ['class' => FileSaveBehavior::className()]);
     $model->addFileAttribute('picture', '@beacon_save_dir', '@beacon_view_dir', '@backend_beacon_view_dir', '@frontend_beacon_view_dir', '@beacon_view_url', function ($attribute, $file_path) {
         HelperImage::resizeByBound($file_path, $file_path, 400);
     });
     $model->saveFiles();
     echo json_encode(['filelink' => $model->getFile('picture')]);
 }
示例#2
0
 public function behaviors()
 {
     return [FileSaveBehavior::className()];
 }