74 parent::__construct($name);
76 $this->_imgInfo = getimagesize($_FILES[$name][
'tmp_name']);
79 $this->_path = dirname($_SERVER[
'SCRIPT_FILENAME']) .
'/img/upload';
99 $this->_minWidth = $value;
109 $this->_maxWidth = $value;
119 $this->_minHeight = $value;
129 $this->_maxHeight = $value;
140 if (!is_writable($this->_path)) {
141 Flash::error(
'Error: no se puede escribir en el directorio');
154 if ($this->_minWidth !== NULL) {
155 if ($image[0] < $this->_minWidth) {
156 Flash::error(
"Error: el ancho de la imagen debe ser superior o igual a {$this->_minWidth}px");
162 if ($this->_maxWidth !== NULL) {
163 if ($image[0] > $this->_maxWidth) {
164 Flash::error(
"Error: el ancho de la imagen debe ser inferior o igual a {$this->_maxWidth}px");
170 if ($this->_minHeight !== NULL) {
171 if ($image[1] < $this->_minHeight) {
172 Flash::error(
"Error: el alto de la imagen debe ser superior o igual a {$this->_minHeight}px");
178 if ($this->_maxHeight !== NULL) {
179 if ($image[1] > $this->_maxHeight) {
180 Flash::error(
"Error: el alto de la imagen debe ser inferior o igual a {$this->_maxHeight}px");
186 return parent::_validates();
197 if (!$this->_imgInfo)
return FALSE;
199 foreach ($this->_types as $type) {
200 if ($this->_imgInfo[
'mime'] ==
"image/$type")
return TRUE;
214 return move_uploaded_file($_FILES[$this->_name][
'tmp_name'],
"$this->_path/$name");