Hi i whant to do a multiple upload.
but im get error : [font="Verdana"][size="2"]mkdir(): No such file or directory[/size][/font]
[font="Verdana"][size="2"]can anyone help me?[/size][/font]
[font="Verdana"][size="2"]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,
));
}}
[/size][/font]