Skip to content

Instantly share code, notes, and snippets.

@AbeCole
Created November 14, 2013 17:55
Show Gist options
  • Save AbeCole/7471291 to your computer and use it in GitHub Desktop.
Save AbeCole/7471291 to your computer and use it in GitHub Desktop.
Modification to ExpressionEngine's CodeIgniter based Upload library. Forces directories to be created if they don't exist. CodeIgniter/system/libraries/Upload.php
// --------------------------------------------------------------------
/**
* Validate Upload Path
*
* Verifies that it is a valid upload path with proper permissions.
*
*
* @return bool
*/
public function validate_upload_path()
{
if ($this->upload_path == '')
{
$this->set_error('upload_no_filepath');
return FALSE;
}
if (function_exists('realpath') AND @realpath($this->upload_path) !== FALSE)
{
$this->upload_path = str_replace("\\", "/", realpath($this->upload_path));
}
if ( ! @is_dir($this->upload_path))
{
if ( ! @mkdir($this->upload_path, 0777))
{
$this->set_error('upload_no_filepath');
return FALSE;
}
}
if ( ! is_really_writable($this->upload_path))
{
$this->set_error('upload_not_writable');
return FALSE;
}
$this->upload_path = preg_replace("/(.+?)\/*$/", "\\1/", $this->upload_path);
return TRUE;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment