1
  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'

1
  • what is in $fileName if you add var_dump($fileName) ? Commented Jun 6, 2014 at 6:05

3 Answers 3

2

I think u miss the "/" after uploads.And after that also if u still have the problem, then try uploading small size files.

Sign up to request clarification or add additional context in comments.

Comments

0

Try to add "/" after uploads:

From:

$uploadedFile->saveAs(Yii::app()->basePath.'/../images/Uploads'.$fileName);

to:

$uploadedFile->saveAs(Yii::app()->basePath.'/../images/Uploads/'.$fileName);

Comments

0

You missed a slash symbol on saveAs()

$uploadedFile->saveAs(Yii::app()->basePath.'/../images/Uploads/'.$fileName);

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.