CI_Upload::validate_upload_path PHP Method

validate_upload_path() public method

Verifies that it is a valid upload path with proper permissions.
public validate_upload_path ( ) : boolean
return boolean
    public function validate_upload_path()
    {
        if ($this->upload_path === '') {
            $this->set_error('upload_no_filepath', 'error');
            return FALSE;
        }
        if (realpath($this->upload_path) !== FALSE) {
            $this->upload_path = str_replace('\\', '/', realpath($this->upload_path));
        }
        if (!is_dir($this->upload_path)) {
            $this->set_error('upload_no_filepath', 'error');
            return FALSE;
        }
        if (!is_really_writable($this->upload_path)) {
            $this->set_error('upload_not_writable', 'error');
            return FALSE;
        }
        $this->upload_path = preg_replace('/(.+?)\\/*$/', '\\1/', $this->upload_path);
        return TRUE;
    }

Usage Example

 /**
  * Validate Upload Path
  *
  * Verifies that it is a valid upload path with proper permissions.
  *
  * @access	public
  */
 public function validate_upload_path()
 {
     if ($this->use_temp_dir) {
         $path = $this->_discover_temp_path();
         if ($path) {
             $this->upload_path = $path;
         } else {
             $this->set_error('No usable temp directory found.');
             return FALSE;
         }
     }
     return parent::validate_upload_path();
 }