Index: downloadDatabase/files/lib/data/downloadDB/DownloadDBDataEditor.class.php
===================================================================
--- downloadDatabase/files/lib/data/downloadDB/DownloadDBDataEditor.class.php (revision 523)
+++ downloadDatabase/files/lib/data/downloadDB/DownloadDBDataEditor.class.php (revision 668)
@@ -56,5 +56,5 @@
 		$size = self::getFileSize($tmpName, $field);
 		// copy file to download folder
-		if (!@copy($tmpName, WCF_DIR.DOWNLOADDB_PREVIEW_DIR.$this->dataID.'_'.StringUtil::encodeHTML($name))) {
+		if (!@copy($tmpName, WCF_DIR.DOWNLOADDB_PREVIEW_DIR.'Preview-'.$this->dataID.'.'.$fileExtension)) {
 			// copy failed
 			// delete file
@@ -63,19 +63,22 @@
 		}
 		// make thumbnail
-		$thumb = new Thumbnail(WCF_DIR.DOWNLOADDB_PREVIEW_DIR.$this->dataID.'_'.StringUtil::encodeHTML($name), DOWNLOADDB_PREVIEW_WIDTH, DOWNLOADDB_PREVIEW_HIGHT);
+		$thumb = new Thumbnail(WCF_DIR.DOWNLOADDB_PREVIEW_DIR.'Preview-'.$this->dataID.'.'.$fileExtension, DOWNLOADDB_PREVIEW_WIDTH, DOWNLOADDB_PREVIEW_HIGHT);
 		// get thumbnail
 		if (($thumbnailData = $thumb->makeThumbnail(true))) {
 			// save thumbnail
-			$file = new File(WCF_DIR.DOWNLOADDB_PREVIEW_DIR.'thumbnail-'.$this->dataID.'_'.StringUtil::encodeHTML($name));
+			$file = new File(WCF_DIR.DOWNLOADDB_PREVIEW_DIR.'thumbnail-'.$this->dataID.'.'.$fileExtension);
 			$file->write($thumbnailData);
 			unset($thumbnailData);
 			$file->close();
-			@chmod(WCF_DIR.DOWNLOADDB_PREVIEW_DIR.'thumbnail-'.$this->dataID.'_'.StringUtil::encodeHTML($name), 0666);
+			@chmod(WCF_DIR.DOWNLOADDB_PREVIEW_DIR.'thumbnail-'.$this->dataID.'.'.$fileExtension, 0666);
 		}		
 		// set permissions
-		@chmod(WCF_DIR.DOWNLOADDB_PREVIEW_DIR.$this->dataID.'_'.StringUtil::encodeHTML($name), 0666);
+		@chmod(WCF_DIR.DOWNLOADDB_PREVIEW_DIR.'Preview-'.$this->dataID.'.'.$fileExtension, 0666);
 		// creat Link
-		$link = DOWNLOADDB_PREVIEW_DIR.$this->dataID.'_'.StringUtil::encodeHTML($name);
-
+		if(file_exists(WCF_DIR.DOWNLOADDB_PREVIEW_DIR.$this->dataID.'_'.StringUtil::encodeHTML($name))){
+			$link = DOWNLOADDB_PREVIEW_DIR.$this->dataID.'_'.StringUtil::encodeHTML($name);
+		} else {
+			$link = DOWNLOADDB_PREVIEW_DIR.'Preview-'.$this->dataID.'.'.$fileExtension;
+		}
 		// reset cache
 		parent::resetCache();
@@ -149,5 +152,5 @@
 
 		// copy file to download folder
-		if (!@copy($tmpName, WCF_DIR.DOWNLOADDB_FILE_DIR.$dataID.'_'.$name)) {
+		if (!@copy($tmpName, WCF_DIR.DOWNLOADDB_FILE_DIR.'Upload-'.$dataID.'.'.$fileExtension)) {
 			// copy failed
 			// delete file
@@ -160,6 +163,6 @@
 		}
 		// set permissions
-		@chmod(WCF_DIR.DOWNLOADDB_FILE_DIR.$dataID.'_'.StringUtil::encodeHTML($name), 0666);
-
+		@chmod(WCF_DIR.DOWNLOADDB_FILE_DIR.'Upload-'.$dataID.'.'.$fileExtension, 0666);
+		
 		return $dataID;
 	}
@@ -176,12 +179,15 @@
 	public function updateFile($fileOld, $tmpName, $name, $mimeType, $field) {
 
-		// get file extension
+		// get file extension of new File
 		$fileExtension = self::getFileExtension($name, $field, DOWNLOADDB_ALLOWED_FILE_EXT);
-		
+		// get file extension of old File
+		if (!empty($fileOld) && StringUtil::indexOf($fileOld, '.') !== false) {
+			$fExt = StringUtil::toLowerCase(StringUtil::substring($fileOld, StringUtil::lastIndexOf($fileOld, '.') + 1));
+		}
 		// check size again
 		$size = self::getFileSize($tmpName, $field);
 				
 		// copy file to download folder
-		if (!@copy($tmpName, WCF_DIR.DOWNLOADDB_FILE_DIR.$this->dataID.'_'.$name)) {
+		if (!@copy($tmpName, WCF_DIR.DOWNLOADDB_FILE_DIR.'Upload_neu-'.$this->dataID.'.'.$fileExtension)) {
 			// copy failed
 			// delete file
@@ -189,8 +195,9 @@
 			throw new UserInputException($field, 'copyFailed');
 		}
+		// delete old File
+		@unlink(WCF_DIR.DOWNLOADDB_FILE_DIR.'Upload-'.$this->dataID.'.'.$fExt);
+		@rename(WCF_DIR.DOWNLOADDB_FILE_DIR.'Upload_neu-'.$this->dataID.'.'.$fileExtension, WCF_DIR.DOWNLOADDB_FILE_DIR.'Upload'.$dataID.'.'.$fileExtension);
 		// set permissions
-		@chmod(WCF_DIR.DOWNLOADDB_FILE_DIR.$this->dataID.'_'.$name, 0666);
-		// delete old file
-		@unlink(WCF_DIR.DOWNLOADDB_FILE_DIR.$this->dataID.'_'.$fileOld);
+		@chmod(WCF_DIR.DOWNLOADDB_FILE_DIR.'Upload-'.$this->dataID.'.'.$fileExtension, 0666);
 
 		// edit file in database
