Quantcast
Channel: Yii Framework Forum
Viewing all articles
Browse latest Browse all 18717

Mkdir(): No Such File Or Directory

$
0
0
Hi i whant to do a multiple upload.
but im get error : mkdir(): No such file or directory

can anyone help me?

My code:
public function actionCreate($id)
	{
		$model=new Galeria;
        if(isset($_POST['Galeria']))
        {
            $model->attributes=$_POST['Galeria'];

            $model->carpeta=$id;
            $carpeta = $model->carpeta.$model->id;

            if(!is_dir(Yii::getPathOfAlias('webroot').'/assets/empresas/'.$carpeta)) {
            mkdir(Yii::getPathOfAlias('webroot').'/assets/empresas/'.$carpeta);
            chmod(Yii::getPathOfAlias('webroot').'/assets/empresas/'.$carpeta, 0644);}

            $imagen = CUploadedFile::getInstancesByName('imagenes');

            // proceed if the images have been set
            if (isset($imagenes) && count($images) > 0) {

                // go through each uploaded image
                foreach ($images as $image => $pic) {
                    echo $pic->name.'<br />';
                    if ($pic->saveAs(Yii::getPathOfAlias('webroot').'/assets/empresas/'.$carpeta.'/'.$pic->name)) {
                        // add it to the main model now
                        $img_add = new Galeria();
                        $img_add->imagen = $pic->name; //it might be $img_add->name for you, filename is just what I chose to call it in my model
                        $img_add->topic_id = $model->empresa_id; // this links your picture model to the main model (like your user, or profile model)

                        $img_add->save(); // DONE
                    }
                    else echo "error" ;
                    // handle the errors here, if you want
                }

                // save the rest of your information from the form



			if($model->save())
				$this->redirect(array('view','id'=>$model->id));
		}

		$this->render('create',array(
			'model'=>$model,
		));
	}}


Viewing all articles
Browse latest Browse all 18717

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>