Reputation: 67
public function actionCreate()
{
$model=new Add;
// Uncomment the following line if AJAX validation is needed
// $this->performAjaxValidation($model);
if(isset($_POST['yt0']))
{
//$rnd = rand(0,9999); // generate random number between 0-9999
$model->attributes=$_POST['Add'];
$uploadedFile=CUploadedFile::getInstance($model,'add_videolink');
//$fileName = "{$rnd}-{$upenter code hereloadedFile}"; // random number + file name
$model->add_videolink = $uploadedFile;
// var_dump($model->save());exit();
if($model->save())
{
if(!empty($uploadedFile))
{
$uploadedFile->saveAs(Yii::app()->basePath.'/../images/Uploads'.$fileName);
}
$this->redirect(array('admin'));
}
}
$this->render('create',array(
'model'=>$model,
));
}
And when i tried to run this code it displays "move_uploaded_file():" The second argument to copy() function cannot be a directory'
Upvotes: 1
Views: 150
Reputation: 58
I think u miss the "/" after uploads.And after that also if u still have the problem, then try uploading small size files.
Upvotes: 2
Reputation: 151
You missed a slash symbol on saveAs()
$uploadedFile->saveAs(Yii::app()->basePath.'/../images/Uploads/'.$fileName);
Upvotes: 0
Reputation: 6791
Try to add "/" after uploads:
From:
$uploadedFile->saveAs(Yii::app()->basePath.'/../images/Uploads'.$fileName);
to:
$uploadedFile->saveAs(Yii::app()->basePath.'/../images/Uploads/'.$fileName);
Upvotes: 0