Index: trunk/core/kernel/utility/formatters/upload_formatter.php =================================================================== diff -u -N -r8686 -r8693 --- trunk/core/kernel/utility/formatters/upload_formatter.php (.../upload_formatter.php) (revision 8686) +++ trunk/core/kernel/utility/formatters/upload_formatter.php (.../upload_formatter.php) (revision 8693) @@ -84,43 +84,34 @@ return getArrayValue($value, 'upload'); } - if ( is_array($value) && $value['size'] ) - { - if ( is_array($value) && $value['error'] === UPLOAD_ERR_OK ) - { - if ( getArrayValue($options, 'allowed_types') && !in_array($value['type'], $options['allowed_types']) ) - { + if (is_array($value) && count($value) > 1 && $value['size']) { + if (is_array($value) && $value['error'] === UPLOAD_ERR_OK) { + $max_filesize = isset($options['max_size']) ? $options['max_size'] : MAX_UPLOAD_SIZE; + + if (getArrayValue($options, 'allowed_types') && !in_array($value['type'], $options['allowed_types'])) { $object->FieldErrors[$field_name]['pseudo'] = 'bad_file_format'; } - elseif ( $value['size'] > ($options['max_size'] ? $options['max_size'] : MAX_UPLOAD_SIZE) ) - { + elseif ($value['size'] > $max_filesize) { $object->FieldErrors[$field_name]['pseudo'] = 'bad_file_size'; } - elseif ( !is_writable($this->FullPath) ) - { + elseif (!is_writable($this->FullPath)) { $object->FieldErrors[$field_name]['pseudo'] = 'cant_save_file'; } - else - { + else { $real_name = $this->ValidateFileName($this->FullPath, $value['name']); $file_name = $this->FullPath.$real_name; - if ( !move_uploaded_file($value['tmp_name'], $file_name) ) - { + if (!move_uploaded_file($value['tmp_name'], $file_name)) { $object->FieldErrors[$field_name]['pseudo'] = 'cant_save_file'; } - else - { + else { @chmod($file_name, 0666); - if(getArrayValue($options, 'size_field')) - { + if (getArrayValue($options, 'size_field')) { $object->SetDBField($options['size_field'], $value['size']); } - if(getArrayValue($options, 'orig_name_field')) - { + if (getArrayValue($options, 'orig_name_field')) { $object->SetDBField($options['orig_name_field'], $value['name']); } - if(getArrayValue($options, 'content_type_field')) - { + if (getArrayValue($options, 'content_type_field')) { $object->SetDBField($options['content_type_field'], $value['type']); } $ret = getArrayValue($options, 'upload_dir') ? $real_name : $this->DestinationPath.$real_name; @@ -133,21 +124,17 @@ } } } - else - { + else { $object->FieldErrors[$field_name]['pseudo'] = 'cant_save_file'; } } - else - { - if(getArrayValue($options, 'required')) - { + else { + if (getArrayValue($options, 'required')) { $object->FieldErrors[$field_name]['pseudo'] = 'required'; } } - if ($value['error'] && !( $value['error'] == UPLOAD_ERR_NO_FILE ) && !$object->FieldErrors[$field_name]['pseudo']) - { + if ((count($value) > 1) && $value['error'] && ($value['error'] != UPLOAD_ERR_NO_FILE) && !$object->FieldErrors[$field_name]['pseudo']) { $object->FieldErrors[$field_name]['pseudo'] = 'cant_save_file'; }