Feature #6039: TCA group -> file absolute path without uploadfolder extended (Thanks...
authorChristian Kuhn <lolli@schwarzbu.ch>
Sat, 1 Aug 2009 18:11:03 +0000 (18:11 +0000)
committerChristian Kuhn <lolli@schwarzbu.ch>
Sat, 1 Aug 2009 18:11:03 +0000 (18:11 +0000)
git-svn-id: https://svn.typo3.org/TYPO3v4/Core/trunk@5744 709f56b5-9817-0410-a4d7-c38de5d9e867

ChangeLog
t3lib/class.t3lib_admin.php
t3lib/class.t3lib_refindex.php
t3lib/class.t3lib_tceforms.php
t3lib/class.t3lib_tcemain.php
typo3/sysext/impexp/class.tx_impexp.php

index 830ac11..e6ed57d 100755 (executable)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2009-08-01  Christian Kuhn  <lollli@schwarzbu.ch>
+
+       * Feature #6039: TCA group -> file absolute path without uploadfolder extended (Thanks to Martin Borer)
+
 2009-07-31  Rupert Germann  <rupi@gmx.li>
 
        * Follow-up for bug #11410: Speed up BEgetRootLine even more by adding a real 2-level cache
index 78fb654..535ccbb 100644 (file)
@@ -582,6 +582,31 @@ class t3lib_admin {
         */
        function testFileRefs ()        {
                $output=Array();
+                       // handle direct references with upload folder setting (workaround)
+               $newCheckFileRefs = array();
+               foreach ($this->checkFileRefs as $folder => $files) {
+                               // only direct references without a folder setting
+                       if ($folder !== '') {
+                               $newCheckFileRefs[$folder] = $files;
+                               continue;
+                       }
+
+                       foreach ($files as $file => $references) {
+
+                                       // direct file references have often many references (removes occurences in the moreReferences section of the result array)
+                               if ($references > 1) {
+                                       $references = 1;
+                               }
+
+                                       // the directory must be empty (prevents checking of the root directory)
+                               $directory = dirname($file);
+                               if ($directory !== '') {
+                                       $newCheckFileRefs[$directory][basename($file)] = $references;
+                               }
+                       }
+               }
+               $this->checkFileRefs = $newCheckFileRefs;
+
                reset($this->checkFileRefs);
                while(list($folder,$fileArr)=each($this->checkFileRefs))        {
                        $path = PATH_site.$folder;
@@ -600,7 +625,8 @@ class t3lib_admin {
                                                        }
                                                        unset($fileArr[$entry]);
                                                } else {
-                                                       if (!strstr($entry,'index.htm'))        {
+                                                               // contains workaround for direct references
+                                                       if (!strstr($entry, 'index.htm') && !preg_match('/^' . preg_quote($GLOBALS['TYPO3_CONF_VARS']['BE']['fileadminDir'], '/') . '/', $folder)) {
                                                                $output['noReferences'][] = Array($path,$entry);
                                                        }
                                                }
@@ -610,6 +636,12 @@ class t3lib_admin {
                                reset($fileArr);
                                $tempCounter=0;
                                while(list($file,)=each($fileArr))      {
+                                               // workaround for direct file references
+                                       if (preg_match('/^' . preg_quote($GLOBALS['TYPO3_CONF_VARS']['BE']['fileadminDir'], '/') . '/', $folder)) {
+                                               $file = $folder . '/' . $file;
+                                               $folder = '';
+                                               $path = substr(PATH_site, 0, - 1);
+                                       }
                                        $temp = $this->whereIsFileReferenced($folder,$file);
                                        $tempList = '';
                                        while(list(,$inf)=each($temp))  {
index e179979..e7ac54b 100644 (file)
@@ -201,6 +201,7 @@ class t3lib_refindex {
                                                case 'db':
                                                        $this->createEntryData_dbRels($table,$uid,$fieldname,'',$deleted,$dat['itemArray']);
                                                break;
+                                               case 'file_reference':
                                                case 'file':
                                                        $this->createEntryData_fileRels($table,$uid,$fieldname,'',$deleted,$dat['newValueFiles']);
                                                break;
@@ -338,6 +339,7 @@ class t3lib_refindex {
                                                                        list($tableName,$recordId) = explode(':',$el['subst']['recordRef']);
                                                                        $this->relations[] = $this->createEntryData($table,$uid,$fieldname,$flexpointer,$deleted,$tableName,$recordId,'',-1,$spKey,$subKey);
                                                                 break;
+                                                                case 'file_reference':
                                                                 case 'file':
                                                                        $this->relations[] = $this->createEntryData($table,$uid,$fieldname,$flexpointer,$deleted,'_FILE',0,$el['subst']['relFileName'],-1,$spKey,$subKey);
                                                                 break;
@@ -533,7 +535,7 @@ class t3lib_refindex {
         */
        function getRelations_procFiles($value, $conf, $uid)    {
                        // Take care of files...
-               if ($conf['type']=='group' && $conf['internal_type']=='file')   {
+               if ($conf['type'] == 'group' && ($conf['internal_type'] == 'file' || $conf['internal_type'] == 'file_reference')) {
 
                                // Collect file values in array:
                        if ($conf['MM'])        {
@@ -551,7 +553,7 @@ class t3lib_refindex {
                        }
 
                                // Traverse the files and add them:
-                       $uploadFolder = $conf['uploadfolder'];
+                       $uploadFolder = $conf['internal_type'] == 'file' ? $conf['uploadfolder'] : '';
                        $dest = $this->destPathFromUploadFolder($uploadFolder);
                        $newValue = array();
                        $newValueFiles = array();
@@ -561,7 +563,7 @@ class t3lib_refindex {
                                        $realFile = $dest.'/'.trim($file);
 #                                      if (@is_file($realFile))        {               // Now, the refernece index should NOT look if files exist - just faithfully include them if they are in the records!
                                                $newValueFiles[] = array(
-                                                       'filename' => $file,
+                                                       'filename' => basename($file),
                                                        'ID' => md5($realFile),
                                                        'ID_absFile' => $realFile
                                                );      // the order should be preserved here because.. (?)
@@ -664,6 +666,7 @@ class t3lib_refindex {
                                                                        $error = $this->setReferenceValue_dbRels($refRec,$dat['itemArray'],$newValue,$dataArray);
                                                                        if ($error)     return $error;
                                                                break;
+                                                               case 'file_reference':
                                                                case 'file':
                                                                        $this->setReferenceValue_fileRels($refRec,$dat['newValueFiles'],$newValue,$dataArray);
                                                                        if ($error)     return $error;
@@ -971,6 +974,9 @@ class t3lib_refindex {
         * @return      string          Input folder prefixed with PATH_site. No checking for existence is done. Output must be a folder without trailing slash.
         */
        function destPathFromUploadFolder($folder)      {
+               if (!$folder) {
+                       return substr(PATH_site, 0, -1);
+               }
                return PATH_site.$folder;
        }
 
index dea8e6c..575cc39 100644 (file)
@@ -2061,6 +2061,9 @@ class t3lib_TCEforms      {
 
                        // Acting according to either "file" or "db" type:
                switch((string)$config['internal_type'])        {
+                       case 'file_reference':
+                               $config['uploadfolder'] = '';
+                               // Fall through
                        case 'file':    // If the element is of the internal type "file":
 
                                        // Creating string showing allowed types:
@@ -2095,7 +2098,7 @@ class t3lib_TCEforms      {
                                                $rowCopy[$field] = $imgPath;
 
                                                        // Icon + clickmenu:
-                                               $absFilePath = t3lib_div::getFileAbsFileName($config['uploadfolder'].'/'.$imgPath);
+                                               $absFilePath = t3lib_div::getFileAbsFileName($config['uploadfolder'] ? $config['uploadfolder'] . '/' . $imgPath : $imgPath);
 
                                                $fI = pathinfo($imgPath);
                                                $fileIcon = t3lib_BEfunc::getFileIcon(strtolower($fI['extension']));
@@ -2127,7 +2130,9 @@ class t3lib_TCEforms      {
 
                                if(!$disabled && !(isset($config['disable_controls']) && t3lib_div::inList($config['disable_controls'], 'upload'))) {
                                                // Adding the upload field:
-                                       if ($this->edit_docModuleUpload)        $item.='<input type="file" name="'.$PA['itemFormElName_file'].'"'.$this->formWidth().' size="60" />';
+                                       if ($this->edit_docModuleUpload && $config['uploadfolder']) {
+                                               $item .= '<input type="file" name="' . $PA['itemFormElName_file'] . '"' . $this->formWidth() . ' size="60" />';
+                                       }
                                }
                        break;
                        case 'folder':  // If the element is of the internal type "folder":
@@ -3459,7 +3464,14 @@ class t3lib_TCEforms     {
                                                }
                                        }
                                break;
+                               case 'file_reference':
                                case 'file':
+                                       foreach ($itemArray as $item) {
+                                               $itemParts = explode('|', $item);
+                                               $uidList[] = $pUid = $pTitle = $itemParts[0];
+                                               $opt[] = '<option value="' . htmlspecialchars(rawurldecode($itemParts[0])) . '">' . htmlspecialchars(basename(rawurldecode($itemParts[0]))) . '</option>';
+                                       }
+                               break;
                                case 'folder':
                                        while(list(,$pp)=each($itemArray))      {
                                                $pParts = explode('|',$pp);
@@ -3502,7 +3514,7 @@ class t3lib_TCEforms      {
                                }
                                $aOnClick='setFormValueOpenBrowser(\''.$mode.'\',\''.($fName.'|||'.$allowed.'|'.$aOnClickInline).'\'); return false;';
                                $icons['R'][]='<a href="#" onclick="'.htmlspecialchars($aOnClick).'">'.
-                                               '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/insert3.gif','width="14" height="14"').' border="0" '.t3lib_BEfunc::titleAltAttrib($this->getLL('l_browse_'.($mode=='file'?'file':'db'))).' />'.
+                                               '<img' . t3lib_iconWorks::skinImg($this->backPath, 'gfx/insert3.gif', 'width="14" height="14"') . ' border="0" ' . t3lib_BEfunc::titleAltAttrib($this->getLL('l_browse_' . ($mode == 'db' ? 'db' : 'file'))) . ' />' .
                                                '</a>';
                        }
                        if (!$params['dontShowMoveIcons'])      {
@@ -3527,23 +3539,20 @@ class t3lib_TCEforms    {
                        $clipElements = $this->getClipboardElements($allowed,$mode);
                        if (count($clipElements))       {
                                $aOnClick = '';
-       #                       $counter = 0;
                                foreach($clipElements as $elValue)      {
-                                       if ($mode=='file')      {
-                                               $itemTitle = 'unescape(\''.rawurlencode(basename($elValue)).'\')';
-                                       } else {        // 'db' mode assumed
+                                       if ($mode == 'db') {
                                                list($itemTable,$itemUid) = explode('|', $elValue);
                                                $itemTitle = $GLOBALS['LANG']->JScharCode(t3lib_BEfunc::getRecordTitle($itemTable, t3lib_BEfunc::getRecordWSOL($itemTable,$itemUid)));
                                                $elValue = $itemTable.'_'.$itemUid;
+                                       } else {
+                                                       // 'file', 'file_reference' and 'folder' mode
+                                               $itemTitle = 'unescape(\'' . rawurlencode(basename($elValue)) . '\')';
                                        }
                                        $aOnClick.= 'setFormValueFromBrowseWin(\''.$fName.'\',unescape(\''.rawurlencode(str_replace('%20',' ',$elValue)).'\'),'.$itemTitle.');';
-
-       #                               $counter++;
-       #                               if ($params['maxitems'] && $counter >= $params['maxitems'])     {       break;  }       // Makes sure that no more than the max items are inserted... for convenience.
                                }
                                $aOnClick.= 'return false;';
                                $icons['R'][]='<a href="#" onclick="'.htmlspecialchars($aOnClick).'">'.
-                                               '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/insert5.png','width="14" height="14"').' border="0" '.t3lib_BEfunc::titleAltAttrib(sprintf($this->getLL('l_clipInsert_'.($mode=='file'?'file':'db')),count($clipElements))).' />'.
+                                               '<img' . t3lib_iconWorks::skinImg($this->backPath, 'gfx/insert5.png', 'width="14" height="14"') . ' border="0" ' . t3lib_BEfunc::titleAltAttrib(sprintf($this->getLL('l_clipInsert_' . ($mode == 'db' ? 'db' : 'file')), count($clipElements))) . ' />' .
                                                '</a>';
                        }
                        $rOnClick = $rOnClickInline.'setFormValueManipulate(\''.$fName.'\',\'Remove\'); return false';
@@ -3595,6 +3604,7 @@ class t3lib_TCEforms      {
 
                if (is_object($this->clipObj))  {
                        switch($mode)   {
+                               case 'file_reference':
                                case 'file':
                                        $elFromTable = $this->clipObj->elFromTable('_FILE');
                                        $allowedExts = t3lib_div::trimExplode(',', $allowed, 1);
@@ -5906,7 +5916,14 @@ class t3lib_TCEforms     {
         * @return      string          HTML formatted output
         */
        function previewFieldValue($value, $config)     {
-               if ($config['config']['type']==='group' && $config['config']['internal_type'] === 'file')       {
+               if ($config['config']['type']==='group' &&
+                               ($config['config']['internal_type'] === 'file' ||
+                               $config['config']['internal_type'] === 'file_reference')) {
+                               // Ignore uploadfolder if internal_type is file_reference
+                       if ($config['config']['internal_type'] === 'file_reference') {
+                               $config['config']['uploadfolder'] = '';
+                       }
+
                        $show_thumbs = TRUE;
                        $table = 'tt_content';
 
@@ -5925,7 +5942,7 @@ class t3lib_TCEforms      {
                                        $rowCopy[$field] = $imgPath;
 
                                                // Icon + clickmenu:
-                                       $absFilePath = t3lib_div::getFileAbsFileName($config['config']['uploadfolder'].'/'.$imgPath);
+                                       $absFilePath = t3lib_div::getFileAbsFileName($config['config']['uploadfolder'] ? $config['config']['uploadfolder'] . '/' . $imgPath : $imgPath);
 
                                        $fI = pathinfo($imgPath);
                                        $fileIcon = t3lib_BEfunc::getFileIcon(strtolower($fI['extension']));
index d40fd04..27ccf9c 100644 (file)
@@ -261,6 +261,7 @@ class t3lib_TCEmain {
        var $defaultValues = array();                   // Array [table][fields]=value: New records are created with default values and you can set this array on the form $defaultValues[$table][$field] = $value to override the default values fetched from TCA. If ->setDefaultsFromUserTS is called UserTSconfig default values will overrule existing values in this array (thus UserTSconfig overrules externally set defaults which overrules TCA defaults)
        var $overrideValues = array();                  // Array [table][fields]=value: You can set this array on the form $overrideValues[$table][$field] = $value to override the incoming data. You must set this externally. You must make sure the fields in this array are also found in the table, because it's not checked. All columns can be set by this array!
        var $alternativeFileName = array();             // Array [filename]=alternative_filename: Use this array to force another name onto a file. Eg. if you set ['/tmp/blablabal'] = 'my_file.txt' and '/tmp/blablabal' is set for a certain file-field, then 'my_file.txt' will be used as the name instead.
+       var $alternativeFilePath = array();             // Array [filename]=alternative_filepath: Same as alternativeFileName but with relative path to the file 
        var $data_disableFields=array();                // If entries are set in this array corresponding to fields for update, they are ignored and thus NOT updated. You could set this array from a series of checkboxes with value=0 and hidden fields before the checkbox with 1. Then an empty checkbox will disable the field.
        var $suggestedInsertUids=array();               // Use this array to validate suggested uids for tables by setting [table]:[uid]. This is a dangerous option since it will force the inserted record to have a certain UID. The value just have to be true, but if you set it to "DELETE" it will make sure any record with that UID will be deleted first (raw delete). The option is used for import of T3D files when synchronizing between two mirrored servers. As a security measure this feature is available only for Admin Users (for now)
 
@@ -1484,6 +1485,7 @@ class t3lib_TCEmain       {
                        // For group types:
                if ($tcaFieldConf['type']=='group')     {
                        switch($tcaFieldConf['internal_type'])  {
+                               case 'file_reference':
                                case 'file':
                                        $valueArray = $this->checkValue_group_select_file(
                                                $valueArray,
@@ -1568,7 +1570,7 @@ class t3lib_TCEmain       {
                }
 
                        // If there is an upload folder defined:
-               if ($tcaFieldConf['uploadfolder'])      {
+               if ($tcaFieldConf['uploadfolder'] && $tcaFieldConf['internal_type'] == 'file') {
                        if (!$this->bypassFileHandling) {       // If filehandling should NOT be bypassed, do processing:
                                        // For logging..
                                $propArr = $this->getRecordProperties($table,$id);
@@ -1699,6 +1701,67 @@ class t3lib_TCEmain      {
                                }
                                $valueArray = $dbAnalysis->countItems();
                        }
+                       //store path relative to site root (if uploadfolder is not set or internal_type is file_reference)
+               } else {
+                       if (count($valueArray)){
+                               if (!$this->bypassFileHandling) {       // If filehandling should NOT be bypassed, do processing:
+                                       $propArr = $this->getRecordProperties($table, $id); // For logging..
+                                       foreach($valueArray as &$theFile){ 
+
+                                                       // if alernative File Path is set for the file, then it was an import
+                                               if ($this->alternativeFilePath[$theFile]){
+
+                                                               // don't import the file if it already exists
+                                                       if (@is_file(PATH_site . $this->alternativeFilePath[$theFile])) {
+                                                               $theFile = PATH_site . $this->alternativeFilePath[$theFile];
+
+                                                               // import the file
+                                                       } elseif (@is_file($theFile)){
+                                                               $dest = dirname(PATH_site . $this->alternativeFilePath[$theFile]);
+                                                               if (!@is_dir($dest)) {
+                                                                       t3lib_div::mkdir_deep(PATH_site, dirname($this->alternativeFilePath[$theFile]) . '/');
+                                                               }
+
+                                                                       // Init:
+                                                               $maxSize = intval($tcaFieldConf['max_size']);
+                                                               $cmd = '';
+                                                               $theDestFile = '';              // Must be cleared. Else a faulty fileref may be inserted if the below code returns an error!
+                                                               $fileSize = filesize($theFile);
+
+                                                               if (!$maxSize || $fileSize <= ($maxSize * 1024))        {       // Check file size:
+                                                                               // Prepare filename:
+                                                                       $theEndFileName = isset($this->alternativeFileName[$theFile]) ? $this->alternativeFileName[$theFile] : $theFile;
+                                                                       $fI = t3lib_div::split_fileref($theEndFileName);
+
+                                                                               // Check for allowed extension:
+                                                                       if ($this->fileFunc->checkIfAllowed($fI['fileext'], $dest, $theEndFileName)) {
+                                                                               $theDestFile = PATH_site . $this->alternativeFilePath[$theFile];
+
+                                                                                       // Write the file:
+                                                                               if ($theDestFile)       {
+                                                                                       t3lib_div::upload_copy_move($theFile, $theDestFile);
+                                                                                       $this->copiedFileMap[$theFile] = $theDestFile;
+                                                                                       clearstatcache();
+                                                                                       if (!@is_file($theDestFile)) $this->log($table, $id, 5, 0, 1, "Copying file '%s' failed!: The destination path (%s) may be write protected. Please make it write enabled!. (%s)", 16, array($theFile, dirname($theDestFile), $recFID), $propArr['event_pid']);
+                                                                               } else $this->log($table, $id, 5, 0, 1, "Copying file '%s' failed!: No destination file (%s) possible!. (%s)", 11, array($theFile, $theDestFile, $recFID), $propArr['event_pid']);
+                                                                       } else $this->log($table, $id, 5, 0, 1, "Fileextension '%s' not allowed. (%s)", 12, array($fI['fileext'], $recFID), $propArr['event_pid']);
+                                                               } else $this->log($table, $id, 5, 0, 1, "Filesize (%s) of file '%s' exceeds limit (%s). (%s)", 13, array(t3lib_div::formatSize($fileSize), $theFile,t3lib_div::formatSize($maxSize * 1024),$recFID), $propArr['event_pid']);
+
+                                                                       // If the destination file was created, we will set the new filename in the value array, otherwise unset the entry in the value array!
+                                                               if (@is_file($theDestFile))     {
+                                                                       $theFile = $theDestFile; // The value is set to the new filename
+                                                               } else {
+                                                                       unset($theFile); // The value is set to the new filename
+                                                               }
+                                                       }
+                                               }
+                                               $theFile = t3lib_div::fixWindowsFilePath($theFile);
+                                               if (t3lib_div::isFirstPartOfStr($theFile, PATH_site)) {
+                                                       $theFile = substr($theFile, strlen(PATH_site));
+                                               }
+                                       }
+                               }
+                       }
                }
 
                return $valueArray;
@@ -3149,7 +3212,7 @@ class t3lib_TCEmain       {
        function copyRecord_procFilesRefs($conf, $uid, $value)  {
 
                        // Prepend absolute paths to files:
-               if ($conf['type']=='group' && $conf['internal_type']=='file')   {
+               if ($conf['type'] == 'group' && ($conf['internal_type'] == 'file' || $conf['internal_type'] == 'file_reference')) {
 
                                // Get an array with files as values:
                        if ($conf['MM'])        {
@@ -3169,13 +3232,13 @@ class t3lib_TCEmain     {
                        }
 
                                // Traverse this array of files:
-                       $uploadFolder = $conf['uploadfolder'];
+                       $uploadFolder = $conf['internal_type'] == 'file' ? $conf['uploadfolder'] : '';
                        $dest = $this->destPathFromUploadFolder($uploadFolder);
                        $newValue = array();
 
                        foreach($theFileValues as $file)        {
                                if (trim($file))        {
-                                       $realFile = $dest.'/'.trim($file);
+                                       $realFile = str_replace('//', '/', $dest . '/' . trim($file));
                                        if (@is_file($realFile))        {
                                                $newValue[] = $realFile;
                                        }
@@ -6515,9 +6578,11 @@ $this->log($table,$id,6,0,0,'Stage raised...',30,array('comment'=>$comment,'stag
                t3lib_div::loadTCA($table);
                if (isset($GLOBALS['TCA'][$table]['columns'])) {
                        foreach ($GLOBALS['TCA'][$table]['columns'] as $field => $configArr) {
-                               if ($configArr['config']['type']=='group' && $configArr['config']['internal_type']=='file')     {
-                                       $listArr[]=$field;
-                               }
+                               if ($configArr['config']['type'] == 'group' &&
+                                       ($configArr['config']['internal_type'] == 'file' ||
+                                        $configArr['config']['internal_type'] == 'file_reference')) {
+                                       $listArr[] = $field;
+                               }
                        }
                }
                return $listArr;
@@ -6687,7 +6752,7 @@ $this->log($table,$id,6,0,0,'Stage raised...',30,array('comment'=>$comment,'stag
                global $TCA;
                t3lib_div::loadTCA($table);
                $uploadFolder = $TCA[$table]['columns'][$field]['config']['uploadfolder'];
-               if ($uploadFolder && trim($filelist))   {
+               if ($uploadFolder && trim($filelist) && $TCA[$table]['columns'][$field]['config']['internal_type'] == 'file') {
                        $uploadPath = $this->destPathFromUploadFolder($uploadFolder);
                        $fileArray = explode(',',$filelist);
                        foreach ($fileArray as $theFile) {
index 9c09108..389a0f1 100755 (executable)
@@ -775,6 +775,8 @@ class tx_impexp {
                                $fileRec['filesize'] = filesize($fI['ID_absFile']);
                                $fileRec['filename'] = basename($fI['ID_absFile']);
                                $fileRec['filemtime'] = filemtime($fI['ID_absFile']);
+                                       //for internal type file_reference
+                               $fileRec['relFileRef'] = substr($fI['ID_absFile'], strlen(PATH_site));
                                if ($recordRef) {
                                        $fileRec['record_ref'] = $recordRef.'/'.$fieldname;
                                }
@@ -1159,6 +1161,7 @@ class tx_impexp {
                        // Temporary files stack initialized:
                $this->unlinkFiles = array();
                $this->alternativeFileName = array();
+               $this->alternativeFilePath = array();
 
                        // Write records, first pages, then the rest
                        // Fields with "hard" relations to database, files and flexform fields are kept empty during this run
@@ -1478,6 +1481,7 @@ class tx_impexp {
                $tce->dontProcessTransformations = 1;
                $tce->enableLogging = $this->enableLogging;
                $tce->alternativeFileName = $this->alternativeFileName;
+               $tce->alternativeFilePath = $this->alternativeFilePath;
                return $tce;
        }
 
@@ -1615,6 +1619,7 @@ class tx_impexp {
                                $this->unlinkFiles[] = $tmpFile;
                                if (filesize($tmpFile)==$this->dat['files'][$fI['ID']]['filesize'])     {
                                        $this->alternativeFileName[$tmpFile] = $fI['filename'];
+                                       $this->alternativeFilePath[$tmpFile] = $this->dat['files'][$fI['ID']]['relFileRef'];
 
                                        return $tmpFile;
                                } else $this->error('Error: temporary file '.$tmpFile.' had a size ('.filesize($tmpFile).') different from the original ('.$this->dat['files'][$fI['ID']]['filesize'].')',1);