perochak
(Amjad Mughal)
February 20, 2011, 8:01pm
1
hi,
I am getting in trouble while creating a new folder using mkdir by passing these variables
mkdir(Yii::app()->request->baseUrl.'./images/prix/'.$section,0777);
actually,
I want to create a folder if it does not exist in images/prix folder
here images folder is in the root directory of application, prix folder exists.
It gives the error that
No such file or directory
any help?
eval
(Zamanfoo)
February 20, 2011, 9:30pm
2
I suppose you need basePath instead of baseUrl.[s]
[/s]
I use something like Yii::getPathOfAlias(‘user.avatars’) to get a full path like /var/www/myapp/protected/modules/user/avatars.
P.S: I think it’s better to chmod() after you mkdir() as the way you do it you will get some unexpected results because of umask (at least on *nix systems)
jkofsky
(Jkofsky)
February 21, 2011, 6:16pm
4
PeRoChAk:
hi,
I am getting in trouble while creating a new folder using mkdir by passing these variables
mkdir(Yii::app()->request->baseUrl.'./images/prix/'.$section,0777);
actually,
I want to create a folder if it does not exist in images/prix folder
here images folder is in the root directory of application, prix folder exists.
It gives the error that
No such file or directory
any help?
In mkdir() I remember there is a boolean parameter for having it build the whole tree to the dir you want.
I believe you could use realpath() to find the filesystem path from the Url path:
mkdir(realpath(Yii::app()->request->baseUrl.'./images/prix/'.$section,0777));
eval
(Zamanfoo)
February 21, 2011, 7:31pm
5
No you can’t. realpath() just returns the absolute path name given a relative path. URL has nothing to do there, you need to use a filesystem path parameter.
jkofsky
(Jkofsky)
February 22, 2011, 7:08pm
6
Would it work if we used basePath instead of baseUrl?
mkdir(realpath(Yii::app()->request->basePath.'./images/prix/'.$section,0777));
gusnips
(Gustavo)
February 22, 2011, 7:23pm
7
try to enable recursion , turn on the third parameter