My yii action

public function actionCreate() { $model = new Video(); $uploaded = false; switch (Yii::$app->request->isAjax) { case "youtube": $model->name = Yii::$app->request->post('name'); $model->url = str_replace("watch?v=", "embed/", Yii::$app->request->post('youtube')); break; case "vimeo": $model->name = Yii::$app->request->post('name'); $model->url = Yii::$app->request->post('vimeo'); break; case 'vk': $model->name = Yii::$app->request->post('name'); $model->url = Yii::$app->request->post('vk'); break; default : new InvalidParamException('Not valid data', 400); } if ($model->load($_POST)) { $file = UploadedFile::getInstance($model, 'file'); if ($model->validate()) { $uploaded = $file->saveAs(Video::UPLOAD_DIR); } } if ($uploaded) { return $this->redirect('index'); }else{ return new ServerErrorHttpException('we cannot uplkoad your video ',500); } } 

My angular controller 'use strict';

 main.controller('VideosController', function ($scope, $routeParams, appService) { var video; $scope.save = function () { if ($scope.video) { appService.postData('index.php/site/create', $scope.video).then(function (data) { $scope.alert = { showAlert:true, msg: angular.fromJson(data).mesg, alertClass: 'success' }; }, function (error) { alert("Can't download this video"); }); } }; }); 
  • I can translate your post? - Naumov
  • you get any error? any mistake? - Naumov
  • simply does not write to the database. Redirect on index.php and that's it - Eduard Silchenko

0