Index: branches/5.1.x/core/kernel/db/db_event_handler.php =================================================================== diff -u -N -r13659 -r13667 --- branches/5.1.x/core/kernel/db/db_event_handler.php (.../db_event_handler.php) (revision 13659) +++ branches/5.1.x/core/kernel/db/db_event_handler.php (.../db_event_handler.php) (revision 13667) @@ -1,6 +1,6 @@ Application->GetVar('field'); $options = $object->GetFieldOptions($field); + // set current uploaded file if ($this->Application->GetVar('tmp')) { - $path = WRITEABLE . '/tmp/' . $this->Application->GetVar('id') . '_' . $file; + $options['upload_dir'] = WRITEBALE_BASE . '/tmp/'; + unset($options['include_path']); + $object->SetFieldOptions($field, $options); + + $object->SetDBField($field, $this->Application->GetVar('id') . '_' . $file); } else { - $upload_dir = $options['upload_dir']; + $object->SetDBField($field, $file); + } - if (array_key_exists('include_path', $options) && $options['include_path']) { - // relative path is already included in field - $upload_dir = ''; - } - - $path = FULL_PATH . $upload_dir . $file; + // get url to uploaded file + if ($this->Application->GetVar('thumb')) { + $url = $object->GetField($field, $options['thumb_format']); } + else { + $url = $object->GetField($field, 'full_url'); // don't use "file_urls" format to prevent recursion + } - $path = str_replace('/', DIRECTORY_SEPARATOR, $path); + $file_helper =& $this->Application->recallObject('FileHelper'); + /* @var $file_helper FileHelper */ + $path = $file_helper->urlToPath($url); + if (!file_exists($path)) { exit; } - if ($this->Application->GetVar('thumb')) { - $image_helper =& $this->Application->recallObject('ImageHelper'); - /* @var $image_helper ImageHelper */ - - $path = $image_helper->ResizeImage($path, $options['thumb_format']); - - $base_url = rtrim($this->Application->BaseURL(), '/'); - $path = preg_replace('/^' . preg_quote($base_url, '/') . '(.*)/', FULL_PATH . '\\1', $path); - $path = str_replace('/', DIRECTORY_SEPARATOR, $path); - } - $type = mime_content_type($path); header('Content-Length: ' . filesize($path)); header('Content-Type: ' . $type); header('Content-Disposition: inline; filename="' . $file . '"'); - safeDefine('DBG_SKIP_REPORTING',1); + safeDefine('DBG_SKIP_REPORTING', 1); readfile($path); - exit(); + exit; } /**