Reputation: 531
Here is my code to create a folder named images
$path="".Yii::app()->request->baseUrl."/users/".Yii::app()->session["id"]."/images";
if(!file_exists($path))
{
mkdir($path,0777,true);
echo($path);
}
But the error i am having is
mkdir(): Permission denied (/var/www/yiicapp/protected/models/Statement.php:123)
I am logged in as "bhawin" but it is making owner www-data
Upvotes: 0
Views: 488
Reputation: 22711
Yii::app()->request->baseUrl
it is domain path URL such as http://example.com/yourfolderpath
instead of that you can use relative path of the folder like /var/www/.....
Upvotes: 1
Reputation: 9765
You've got no right to write to given folder and PHP can't change it. You have to use SSH or FTP with user with permissions and change rights to 777.
Upvotes: 1
Reputation: 437386
Yii::app()->request->baseUrl
is a URL, not a local filesystem path. You cannot create directories in a URL.
To work with the filesystem you would need to start from Yii::app()->basePath
instead, although putting user-supplied content in a web-accessible location might not be smart (everyone can view that content if they know the correct URL). Depending on what the content is the correct approach might be to put it outside the web server document root entirely.
Upvotes: 0
Reputation: 3731
You have no rights to create a new folder, so chmod is probably what you need :)
Upvotes: 0