/** * Загрузка изображений * @param type $newNameFile - 1) новое имя изображения * @param type $nameIdInputFile -2) id name input * @param type $idFile - 3) id изображения, если загружено больше одного * @param type $access - 4) строка разрешенных расширений * @param type $fileSize - 5) допустимый размер файла * @param type $extension - 6) новое расширение * @param type $width - 7) ширина изображения * @param type $height - 8) высота изображения * @param type $parameterImage - 9) параметры ресайзa изображения * Может быть: exact - точно по заданным размерам; maxwidth - Ш-неизменна, Д-сохраняет соотношение; * maxheight - Д-неизменна, Ш-сохраняет соотношение; crop - обрезка; по умолчанию - default (авто) */ public function uploadFile($newNameFile, $nameIdInputFile, $idFile = null, $access = null, $fileSize = null, $extension = null, $width = null, $height = null, $parameterImage = null) { parent::uploadFile($newNameFile, $nameIdInputFile, $idFile, $access, $fileSize, $extension); // если файл существует if (file_exists($this->saveNameFile)) { // если допустимые размеры норм if ($this->checkImageSize($this->saveNameFile)) { // если задана только ширина, ресайз будет по ширине с сохранением пропорций if ($width !== null || $height !== null) { if ($width !== null && $height === null) { $this->width = $width; $this->parameterImage = 'maxwidth'; // если задана только высота, ресайз будет по высотe с сохранением пропорций } elseif ($height !== null && $width === null) { $this->height = $height; $this->parameterImage = 'maxheight'; } else { // если задана и ширина и высота if ($width !== null && $width != '' && $height !== null && $height != '') { $this->width = $width; $this->height = $height; // и параметр ресайзa, ресайз будет по значению $parameterImage if ($parameterImage !== null) { $this->parameterImage = $parameterImage; } else { // ресайз будет по default $this->parameterImage = 'default'; } } } $this->resizeImages($this->saveNameFile, $this->width, $this->height, $this->parameterImage); } } else { // если максимальные или минимальные размеры не проходят, сообщаем об ошибке $this->errors[] = ' Файл не загружен'; if (file_exists($this->saveNameFile)) { unlink($this->saveNameFile); } } } else { $this->errors[] = ' Файл не найден'; } }