Skip to content

Commit

Permalink
Writable files do not need writable directories, fixes #1954
Browse files Browse the repository at this point in the history
  • Loading branch information
Woody Gilk committed Aug 20, 2009
1 parent 73c5b9e commit 79fadf9
Showing 1 changed file with 17 additions and 6 deletions.
23 changes: 17 additions & 6 deletions classes/image.php
Original file line number Diff line number Diff line change
Expand Up @@ -501,13 +501,24 @@ public function save($file = NULL, $quality = 100)
$file = $this->file;
}

// Get the directory of the file
$directory = realpath(pathinfo($file, PATHINFO_DIRNAME));

if ( ! is_dir($directory) OR ! is_writable($directory))
if (is_file($file))
{
if ( ! is_writable($file))
{
throw new Kohana_Exception('File must be writable: :file',
array(':file' => Kohana::debug_path($file)));
}
}
else
{
throw new Kohana_Exception('Directory must be writable: :directory',
array(':directory' => Kohana::debug_path($directory)));
// Get the directory of the file
$directory = realpath(pathinfo($file, PATHINFO_DIRNAME));

if ( ! is_dir($directory) OR ! is_writable($directory))
{
throw new Kohana_Exception('Directory must be writable: :directory',
array(':directory' => Kohana::debug_path($directory)));
}
}

return $this->_do_save($file, $quality);
Expand Down

0 comments on commit 79fadf9

Please sign in to comment.