Changeset View
Changeset View
Standalone View
Standalone View
branches/5.2.x/core/kernel/utility/formatters/upload_formatter.php
Show First 20 Lines • Show All 239 Lines • ▼ Show 20 Line(s) | |||||
} | } | ||||
elseif ( !is_writable($this->FullPath) ) { | elseif ( !is_writable($this->FullPath) ) { | ||||
$object->SetError($field_name, 'cant_save_file', 'la_error_cant_save_file'); | $object->SetError($field_name, 'cant_save_file', 'la_error_cant_save_file'); | ||||
} | } | ||||
else { | else { | ||||
$real_name = $this->_getRealFilename($value['name'], $options, $object); | $real_name = $this->_getRealFilename($value['name'], $options, $object); | ||||
$file_name = $this->FullPath . $real_name; | $file_name = $this->FullPath . $real_name; | ||||
$moved = move_uploaded_file($value['tmp_name'], $file_name); | |||||
$storage_format = isset($options['storage_format']) ? $options['storage_format'] : false; | $storage_format = isset($options['storage_format']) ? $options['storage_format'] : false; | ||||
if ( $storage_format ) { | if ( $storage_format ) { | ||||
/** @var ImageHelper $image_helper */ | /** @var kUploadHelper $upload_helper */ | ||||
$image_helper = $this->Application->recallObject('ImageHelper'); | $upload_helper = $this->Application->recallObject('kUploadHelper'); | ||||
$moved = $upload_helper->resizeUploadedFile($file_name, $storage_format); | |||||
move_uploaded_file($value['tmp_name'], $value['tmp_name'] . '.jpg'); // add extension, so ResizeImage can work | |||||
$url = $image_helper->ResizeImage($value['tmp_name'] . '.jpg', $storage_format); | |||||
$tmp_name = preg_replace('/^' . preg_quote($this->Application->BaseURL(), '/') . '/', '/', $url); | |||||
$moved = rename($tmp_name, $file_name); | |||||
} | |||||
else { | |||||
$moved = move_uploaded_file($value['tmp_name'], $file_name); | |||||
} | } | ||||
if ( !$moved ) { | if ( !$moved ) { | ||||
$object->SetError($field_name, 'cant_save_file', 'la_error_cant_save_file'); | $object->SetError($field_name, 'cant_save_file', 'la_error_cant_save_file'); | ||||
} | } | ||||
else { | else { | ||||
@chmod($file_name, 0666); | @chmod($file_name, 0666); | ||||
▲ Show 20 Lines • Show All 385 Lines • Show Last 20 Lines |