Skip to content

Commit

Permalink
Create Default Path if Upload Dir not set
Browse files Browse the repository at this point in the history
If Upload Directory is set then return path. If directory doesn't exists attempt to create it and throw exception if attempt failed i.e. invalid permission.
  • Loading branch information
Rjgoolsby committed Jan 7, 2016
1 parent a9a428d commit bcbcae8
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions RedactorModule.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,13 @@ public function getOwnerPath()
*/
public function getSaveDir()
{
$path = Yii::getAlias($this->uploadDir);
if (!file_exists($path)) {
throw new InvalidConfigException('Invalid config $uploadDir');
}
if (FileHelper::createDirectory($path . DIRECTORY_SEPARATOR . $this->getOwnerPath(), 0777)) {
return $path . DIRECTORY_SEPARATOR . $this->getOwnerPath();
$path = Yii::getAlias($this->uploadDir) . DIRECTORY_SEPARATOR . $this->getOwnerPath();
if(!file_exists($path)){
if (!FileHelper::createDirectory($path, 0775,$recursive = true )) {
throw new InvalidConfigException('$uploadDir does not exist and default path creation failed');
}
}
return $path;
}

/**
Expand Down

1 comment on commit bcbcae8

@eurobalt
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you very mutch for this fix. I almost became crazy while looking for how to hundle with this error

Please sign in to comment.