コード例 #1
0
 public function actionUpload($model_id, $object_id, $tag)
 {
     if ($object_id == 0) {
         $object_id = 'tmp_' . Yii::app()->user->id;
     }
     $model = new MediaFile('insert');
     $model->object_id = $object_id;
     $model->model_id = $model_id;
     $model->tag = $tag;
     if ($model->saveFile() && $model->userCanEdit() && $model->save()) {
         $this->sendFilesAsJson([$model]);
     } else {
         echo CJSON::encode(['textStatus' => $model->error]);
     }
 }