Exemple #1
0
 /**
  * 单例
  * @return object
  */
 public static function instance()
 {
     if (!self::$instance instanceof self) {
         self::$instance = new self();
     }
     return self::$instance;
 }
Exemple #2
0
 /**
  * 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;
 }
Exemple #3
0
 /**
  * Загрузка
  *
  * @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;
 }
Exemple #4
0
 protected function getMimeType($file)
 {
     return is_dir($file) ? 'text/directory' : File_Upload::mime($file);
 }