Index: bug_file_upload_inc.php
===================================================================
--- bug_file_upload_inc.php	(revision 213)
+++ bug_file_upload_inc.php	(working copy)
@@ -69,6 +69,8 @@
 		}
 	}
 ?>
+		<a name="blFileUpload"></a>
+		Bugnote-ID: <input type="text" name="upload_file_bugnote_id" id="upload_file_bugnote_id" value="0" size="3" />
 		<input type="submit" class="button"
 			value="<?php echo lang_get( $t_file_upload_max_num == 1 ? 'upload_file_button' : 'upload_files_button' ) ?>"
 		/>
Index: bugnote_view_inc.php
===================================================================
--- bugnote_view_inc.php	(revision 213)
+++ bugnote_view_inc.php	(working copy)
@@ -221,7 +221,14 @@
 			$note = str_replace(array('<','>'), array('&lt;','&gt;'), $t_bugnote->note); 
 			echo string_display_links(	$note	);
 			//echo string_display_links(	$t_bugnote->note	);
+			
 		?>
+			<br /><hr />
+			<?php
+			print_bug_attachments_list( $tpl_bug_id , $t_bugnote->id );
+			?>
+			<br />-------> <a href="#blFileUpload" onclick="document.getElementById('upload_file_bugnote_id').value='<?php echo $t_bugnote->id; ?>';">Datei hochladen</a> ------->
+
 	</td>
 </tr>
 <?php }else{ ?>
Index: core/bug_api.php
===================================================================
--- core/bug_api.php	(revision 213)
+++ core/bug_api.php	(working copy)
@@ -1405,16 +1405,17 @@
  * @uses database_api.php
  * @uses file_api.php
  */
-function bug_get_attachments( $p_bug_id ) {
+function bug_get_attachments( $p_bug_id , $p_bugnote_id = 0 ) {
 	$c_bug_id = db_prepare_int( $p_bug_id );
+	$c_bugnote_id = db_prepare_int( $p_bugnote_id );
 
 	$t_bug_file_table = db_get_table( 'mantis_bug_file_table' );
 
 	$query = "SELECT id, title, diskfile, filename, filesize, file_type, date_added, user_id
 		                FROM $t_bug_file_table
-		                WHERE bug_id=" . db_param() . "
+		                WHERE bug_id=" . db_param() . " AND bugnote_id=" . db_param() . "
 		                ORDER BY date_added";
-	$db_result = db_query_bound( $query, Array( $c_bug_id ) );
+	$db_result = db_query_bound( $query, Array( $c_bug_id , $c_bugnote_id ) );
 	$num_files = db_num_rows( $db_result );
 
 	$t_result = array();
Index: core/file_api.php
===================================================================
--- core/file_api.php	(revision 213)
+++ core/file_api.php	(working copy)
@@ -244,8 +244,8 @@
 # type - Can be "image", "text" or empty for other types.
 # alt - The alternate text to be associated with the icon.
 # icon - array with icon information, contains 'url' and 'alt' elements.
-function file_get_visible_attachments( $p_bug_id ) {
-	$t_attachment_rows = bug_get_attachments( $p_bug_id );
+function file_get_visible_attachments( $p_bug_id , $p_bugnote_id =0 ) {
+	$t_attachment_rows = bug_get_attachments( $p_bug_id , $p_bugnote_id );
 	$t_visible_attachments = array();
 
 	$t_attachments_count = count( $t_attachment_rows );
@@ -641,6 +641,8 @@
  */
 function file_add( $p_bug_id, $p_file, $p_table = 'bug', $p_title = '', $p_desc = '', $p_user_id = null, $p_date_added = 0, $p_skip_bug_update = false ) {
 
+	$bugnote_id = gpc_get_int('upload_file_bugnote_id', 0); 
+
 	file_ensure_uploaded( $p_file );
 	$t_file_name = $p_file['name'];
 	$t_tmp_file = $p_file['tmp_name'];
@@ -729,14 +731,15 @@
 	$t_id_col = $p_table . "_id";
 
 	$query = "INSERT INTO $t_file_table
-				( $t_id_col, title, description, diskfile, filename, folder, filesize, file_type, date_added, content, user_id )
+				( $t_id_col, bugnote_id, title, description, diskfile, filename, folder, filesize, file_type, date_added, content, user_id )
 			  VALUES
-				( " . db_param() . ", " . db_param() . ", " . db_param() . ", "
+				( " . db_param() . ", " . db_param() . ", " . db_param() . ", " . db_param() . ", "
 				    . db_param() . ", " . db_param() . ", " . db_param() . ", "
 				    . db_param() . ", " . db_param() . ", " . db_param() . ", "
 				    . db_param() . ", " . db_param() . " )";
 	db_query_bound( $query, Array(
 		$t_id,
+		$bugnote_id,
 		$p_title,
 		$p_desc,
 		$t_unique_name,
Index: core/print_api.php
===================================================================
--- core/print_api.php	(revision 213)
+++ core/print_api.php	(working copy)
@@ -1667,8 +1667,8 @@
 
 # List the attachments belonging to the specified bug.  This is used from within
 # bug_view_inc.php
-function print_bug_attachments_list( $p_bug_id ) {
-	$t_attachments = file_get_visible_attachments( $p_bug_id );
+function print_bug_attachments_list( $p_bug_id , $p_bugnote_id = 0) {
+	$t_attachments = file_get_visible_attachments( $p_bug_id, $p_bugnote_id );
 	$t_attachments_count = count( $t_attachments );
 
 	$i = 0;
