Index: t3lib/class.t3lib_refindex.php
===================================================================
--- t3lib/class.t3lib_refindex.php	(revision 4004)
+++ t3lib/class.t3lib_refindex.php	(working copy)
@@ -204,10 +204,11 @@
  					switch((string)$dat['type'])	{
  						case 'db':
  							$this->createEntryData_dbRels($table,$uid,$fieldname,'',$deleted,$dat['itemArray']);
- 						break;
+ 							break;
+						case 'file_reference':
  						case 'file':
  							$this->createEntryData_fileRels($table,$uid,$fieldname,'',$deleted,$dat['newValueFiles']);
- 						break;
+ 							break;
  						case 'flex':
 								// DB references:
 							if (is_array($dat['flexFormRels']['db']))	{
@@ -227,7 +228,7 @@
 									$this->createEntryData_softreferences($table,$uid,$fieldname,$flexpointer,$deleted,$subList['keys']);
 								}
 							}
- 						break;
+							break;
  					}
 
  						// Softreferences in the field:
@@ -342,6 +343,7 @@
 								 	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;
@@ -537,10 +539,10 @@
 	 */
 	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'])	{
+			if ($conf['MM']) {
 				$theFileValues = array();
 				$dbAnalysis = t3lib_div::makeInstance('t3lib_loadDBGroup');
 				$dbAnalysis->start('', 'files', $conf['MM'], $uid);
@@ -555,7 +557,7 @@
 			}
 
 				// Traverse the files and add them:
-			$uploadFolder = $conf['uploadfolder'];
+			$uploadFolder = $conf['internal_type']=='file' ? $conf['uploadfolder'] : '';
 			$dest = $this->destPathFromUploadFolder($uploadFolder);
 			$newValue = array();
 			$newValueFiles = array();
@@ -565,7 +567,7 @@
 					$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.. (?)
@@ -668,6 +670,7 @@
 		 							$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;
@@ -974,8 +977,8 @@
 	 * @param	string		Folder relative to PATH_site
 	 * @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)	{
-		return PATH_site.$folder;
+	function destPathFromUploadFolder($folder) {
+		return $folder ? PATH_site . $folder : substr(PATH_site, 0, -1);
 	}
 
 	/**
Index: t3lib/class.t3lib_tceforms.php
===================================================================
--- t3lib/class.t3lib_tceforms.php	(revision 4004)
+++ t3lib/class.t3lib_tceforms.php	(working copy)
@@ -981,7 +981,7 @@
 				$hookObject->getSingleField_beforeRender($table, $field, $row, $PA);
 			}
 		}
-		
+
 		switch($PA['fieldConf']['config']['form_type'])	{
 			case 'input':
 				$item = $this->getSingleField_typeInput($table,$field,$row,$PA);
@@ -1654,7 +1654,7 @@
 
 			// Get values in an array (and make unique, which is fine because there can be no duplicates anyway):
 		$itemArray = array_flip($this->extractValuesOnlyFromValueLabelList($PA['itemFormElValue']));
-		
+
 		$disabled = '';
 		if($this->renderReadonly || $config['readOnly'])  {
 			$disabled = ' disabled="disabled"';
@@ -2045,9 +2045,11 @@
 
 			// Acting according to either "file" or "db" type:
 		switch((string)$config['internal_type'])	{
-			case 'file':	// If the element is of the internal type "file":
-
-					// Creating string showing allowed types:
+			case 'file_reference':
+				$config['uploadfolder'] = '';
+				// Fall through
+			case 'file':
+				// Creating string showing allowed types:
 				$tempFT = t3lib_div::trimExplode(',',$allowed,1);
 				if (!count($tempFT))	{$info.='*';}
 				foreach($tempFT as $ext)	{
@@ -2111,7 +2113,9 @@
 
 				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":
@@ -3430,12 +3434,13 @@
 						}
 					}
 				break;
+				case 'file_reference':
 				case 'file':
 				case 'folder':
 					while(list(,$pp)=each($itemArray))	{
 						$pParts = explode('|',$pp);
 						$uidList[]=$pUid=$pTitle = $pParts[0];
-						$opt[]='<option value="'.htmlspecialchars(rawurldecode($pParts[0])).'">'.htmlspecialchars(rawurldecode($pParts[0])).'</option>';
+						$opt[]='<option value="'.htmlspecialchars(rawurldecode($pParts[0])).'">'.htmlspecialchars(basename(rawurldecode($pParts[0]))).'</option>';
 					}
 				break;
 				default:
@@ -3473,7 +3478,7 @@
 				}
 				$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'])	{
@@ -3498,23 +3503,20 @@
 			$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';
@@ -3566,6 +3568,7 @@
 
 		if (is_object($this->clipObj))	{
 			switch($mode)	{
+				case 'file_reference':
 				case 'file':
 					$elFromTable = $this->clipObj->elFromTable('_FILE');
 					$allowedExts = t3lib_div::trimExplode(',', $allowed, 1);
@@ -5840,7 +5843,14 @@
 	 * @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';
 
Index: t3lib/class.t3lib_tcemain.php
===================================================================
--- t3lib/class.t3lib_tcemain.php	(revision 4004)
+++ t3lib/class.t3lib_tcemain.php	(working copy)
@@ -1497,6 +1497,7 @@
 			// For group types:
 		if ($tcaFieldConf['type']=='group')	{
 			switch($tcaFieldConf['internal_type'])	{
+				case 'file_reference':
 				case 'file':
 					$valueArray = $this->checkValue_group_select_file(
 						$valueArray,
@@ -1581,7 +1582,7 @@
 		}
 
 			// 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);
@@ -1714,6 +1715,15 @@
 				}
 				$valueArray = $dbAnalysis->countItems();
 			}
+		} else {
+			if (count($valueArray)){
+				// store path relative to site root (if uploadfolder is not set or internal_type is file_reference)
+				foreach($valueArray as &$theFile){
+					if (t3lib_div::isFirstPartOfStr($theFile,PATH_site))	{
+						$theFile = substr($theFile,strlen(PATH_site));
+					}
+				}
+			}
 		}
 
 		return $valueArray;
@@ -3147,11 +3157,11 @@
 	 */
 	function copyRecord_procFilesRefs($conf, $uid, $value)	{
 
-			// Prepend absolute paths to files:
-		if ($conf['type']=='group' && $conf['internal_type']=='file')	{
+		// Prepend absolute paths to files:
+		if ($conf['type'] == 'group' && ($conf['internal_type'] == 'file' || $conf['internal_type'] == 'file_reference')) {
 
 				// Get an array with files as values:
-			if ($conf['MM'])	{
+			if ($conf['MM']) {
 				$theFileValues = array();
 
 				$dbAnalysis = t3lib_div::makeInstance('t3lib_loadDBGroup');
@@ -3168,7 +3178,7 @@
 			}
 
 				// Traverse this array of files:
-			$uploadFolder = $conf['uploadfolder'];
+			$uploadFolder = $conf['internal_type']=='file' ? $conf['uploadfolder'] : '';
 			$dest = $this->destPathFromUploadFolder($uploadFolder);
 			$newValue = array();
 
@@ -6473,8 +6483,10 @@
 		if ($TCA[$table]['columns'])	{
 			reset($TCA[$table]['columns']);
 			while (list($field,$configArr)=each($TCA[$table]['columns']))	{
-				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;
 				}
 			}
 		}
@@ -6642,7 +6654,7 @@
 		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);
 			while (list(,$theFile)=each($fileArray))	{
