/** * 单例 * @return object */ public static function instance() { if (!self::$instance instanceof self) { self::$instance = new self(); } return self::$instance; }
/** * Process elements value from request * * @return */ public function result() { $file = new File_Upload($this->options); if ($result = $file->upload()) { $this->is_fetched = TRUE; $result = File::pathToUri($result->path, UPLOADS); } else { $this->errors = $file->getErrors(); } if (cogear()->input->post($this->name)) { return ''; } if ($this->validate()) { if ($result) { return $result; } return $this->errors ? FALSE : NULL; } return FALSE; }
/** * Загрузка * * @return array|Core_ArrayObject */ public function upload() { if ($result = parent::upload()) { if (is_array($result)) { foreach ($result as $file) { $this->postProcess($file); } } else { $this->postProcess($result); } } return $result; }
protected function getMimeType($file) { return is_dir($file) ? 'text/directory' : File_Upload::mime($file); }