E
E
eddos2016-06-27 22:11:04
Yii
eddos, 2016-06-27 22:11:04

Can't download video from youtube vk and locale using yii2?

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");
});
}
};
});

Answer the question

In order to leave comments, you need to log in

1 answer(s)
P
pantsarny, 2016-06-28
@pantsarny

You are not working correctly with Yii component properties. Check out the documentation.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question