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 236 Lines • ▼ Show 20 Line(s) | |||||
} | } | ||||
elseif ( $value['size'] > $options['max_size'] ) { | elseif ( $value['size'] > $options['max_size'] ) { | ||||
$object->SetError($field_name, 'bad_file_size', 'la_error_FileTooLarge'); | $object->SetError($field_name, 'bad_file_size', 'la_error_FileTooLarge'); | ||||
} | } | ||||
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); | $tmp_path = WRITEABLE . '/tmp/'; | ||||
$file_name = $this->FullPath . $real_name; | $filename = $this->fileHelper->ensureUniqueFilename($tmp_path, $value['name'] . '.tmp'); | ||||
$tmp_file_path = $tmp_path . $filename; | |||||
$moved = move_uploaded_file($value['tmp_name'], $file_name); | $moved = move_uploaded_file($value['tmp_name'], $tmp_file_path); | ||||
$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 kUploadHelper $upload_helper */ | /** @var kUploadHelper $upload_helper */ | ||||
$upload_helper = $this->Application->recallObject('kUploadHelper'); | $upload_helper = $this->Application->recallObject('kUploadHelper'); | ||||
$moved = $upload_helper->resizeUploadedFile($file_name, $storage_format); | $moved = $upload_helper->resizeUploadedFile($tmp_file_path, $storage_format); | ||||
} | |||||
if ( $moved ) { | |||||
$real_name = $this->_getRealFilename( | |||||
kUtil::removeTempExtension(basename($tmp_file_path)), | |||||
$options, | |||||
$object | |||||
); | |||||
$file_name = $this->FullPath . $real_name; | |||||
$moved = rename($tmp_file_path, $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 |