public function test_constructor() { $upload = new Upload_File('default', 'file', 'filename1.txt'); $this->assertInstanceOf('Flex\\Storage\\Server', $upload->server()); $this->assertEquals('file', $upload->path()); $this->assertEquals('filename1.txt', $upload->filename()); }
/** * Process elements value from request * * @return */ public function result() { $cogear = getInstance(); $file = new Upload_File($this->name, $this->getAttributes(), $this->validators->findByValue('Required')); if ($value = $file->upload()) { $this->is_fetched = TRUE; $this->value = $value; } else { $this->errors = $file->errors; } return $this->value; }
/** * (non-PHPdoc) * @see Upload_File::upload() */ public function upload(array $data, $path, $formUpload = true) { $data = parent::upload($data, $path, $formUpload); if (!empty($data) && !empty($this->_config['sizes'])) { foreach ($this->_config['sizes'] as $name => $xy) { $ext = File::getExt($data['path']); $replace = '-' . $name . $ext; $newName = str_replace($ext, $replace, $data['path']); if ($this->_config['thumb_types'][$name] == 'crop') { Image_Resize::resize($data['path'], $xy[0], $xy[1], $newName, true, true); } else { Image_Resize::resize($data['path'], $xy[0], $xy[1], $newName, true, false); } if ($name == 'icon') { $data['thumb'] = $newName; } } } return $data; }
/** * Get upload file object for a given model * * @param Jam_Model $model * @return Upload_File */ public function upload_file(Jam_Model $model) { $upload_file = new Upload_File($this->server, $this->path($model)); if ($this->transformations) { $upload_file->transformations($this->transformations); } if ($this->thumbnails) { $upload_file->thumbnails($this->thumbnails); } return $upload_file; }
/** * Process upload * * @return boolean|string */ protected function processUpload() { $this->getInfo($this->file->tmp_name); if ($this->options->max && !$this->checkMax($this->options->max->width, $this->options->max->height) or $this->options->min && !$this->checkMin($this->options->max->width, $this->options->max->height)) { return FALSE; } return parent::processUpload(); }