Index: /CKEditor/branches/prototype/_source/plugins/dialog/plugin.js
===================================================================
--- /CKEditor/branches/prototype/_source/plugins/dialog/plugin.js	(revision 2659)
+++ /CKEditor/branches/prototype/_source/plugins/dialog/plugin.js	(revision 2660)
@@ -437,4 +437,5 @@
 		// Execute onLoad for the first show.
 		this.fireOnce( 'load', {} );
+		this.fire( 'show', {} );
 	},
 
@@ -481,4 +482,5 @@
 			CKEDITOR.dialog._.currentZIndex -= 10;
 
+		this.fire( 'hide', {} );
 	},
 
@@ -1753,4 +1755,14 @@
 		{
 			dialog.on( 'load', func, this, null, CKEDITOR.tools.getNextNumber() );
+		},
+
+		onShow : function( dialog, func )
+		{
+			dialog.on( 'show', func, this, null, CKEDITOR.tools.getNextNumber() );
+		},
+
+		onHide : function( dialog, func )
+		{
+			dialog.on( 'hide', func, this, null, CKEDITOR.tools.getNextNumber() );
 		}
 	},
Index: /CKEditor/branches/prototype/_source/plugins/dialogui/plugin.js
===================================================================
--- /CKEditor/branches/prototype/_source/plugins/dialogui/plugin.js	(revision 2659)
+++ /CKEditor/branches/prototype/_source/plugins/dialogui/plugin.js	(revision 2660)
@@ -377,5 +377,5 @@
 						html = [],
 						innerHTML = [],
-						attributes = { 'class' : 'cke_dialog_ui_select_input' };
+						attributes = { 'class' : 'cke_dialog_ui_input_select' };
 
 					for ( var i = 0, item ; i < elementDefinition.items.length && ( item = elementDefinition.items[i] ) ; i++ )
@@ -395,4 +395,7 @@
 			/**
 			 * A file upload input.
+			 * @extends CKEDITOR.ui.dialog.labeledElement
+			 * @example
+			 * @constructor
 			 */
 			file : function( dialog, elementDefinition, htmlList )
@@ -406,10 +409,64 @@
 					this.validate = elementDefinition.validate;
 
+				var myDefinition = CKEDITOR.tools.extend( {}, elementDefinition );
+
+				// onLoad doesn't work. The file input needs to be drawn each time the dialog is shown.
+				myDefinition.onShow = function()
+				{
+					var frameElement = CKEDITOR.document.getById( _.frameId ),
+						frameDocument = frameElement.$.contentWindow.document;
+					frameDocument.open();
+					frameDocument.write( [ '<html><head><title></title></head><body style="margin: 0; overflow: hidden;">',
+							'<form enctype="multipart/form-data" method="POST" action="',
+							CKEDITOR.tools.htmlEncode( elementDefinition.action ),
+							'">',
+							'<input type="file" name="',
+							CKEDITOR.tools.htmlEncode( elementDefinition.id || 'cke_upload' ),
+							'" size="',
+							CKEDITOR.tools.htmlEncode( elementDefinition.size || '' ),
+							'" />',
+							'</form>',
+							'</body></html>' ].join( '' ) );
+					frameDocument.close();
+					return elementDefinition.onShow && elementDefinition.onShow.apply( this, arguments );
+				}
+
 				/** @ignore */
 				var innerHTML = function()
 				{
+					_.frameId = CKEDITOR.tools.getNextNumber() + '_fileInput';
+					var html = [ '<iframe frameborder="0" allowtransparency="0" class="cke_dialog_ui_input_file" id="',
+						_.frameId, '" src="javascript: void(0)" ></iframe>' ];
+					return html.join( '' );
 				};
 
-				CKEDITOR.ui.dialog.labeledElement.call( this, dialog, elementDefinition, htmlList, innerHTML );
+				CKEDITOR.ui.dialog.labeledElement.call( this, dialog, myDefinition, htmlList, innerHTML );
+			},
+
+			/**
+			 * A button for submitting the file in a file upload input.
+			 * @extends CKEDITOR.ui.dialog.button
+			 * @example
+			 * @constructor
+			 */
+			fileButton : function( dialog, elementDefinition, htmlList )
+			{
+				if ( arguments.length < 3 )
+					return;
+				
+				var _ = initPrivateObject.call( this, elementDefinition );
+
+				if ( elementDefinition.validate )
+					this.validate = elementDefinition.validate;
+
+				var myDefinition = CKEDITOR.tools.extend( {}, elementDefinition );
+				myDefinition.className = ( myDefinition.className ? myDefinition.className + ' ' : '' ) + 'cke_dialog_ui_button';
+				myDefinition.onClick = function( evt ) 
+				{
+					var target = elementDefinition[ 'for' ];		// [ pageId, elementId ]
+					dialog.getContentElement( target[0], target[1] ).submit();
+				};
+
+				CKEDITOR.ui.dialog.button.call( this, dialog, myDefinition, htmlList );
 			},
 
@@ -453,5 +510,6 @@
 
 	CKEDITOR.ui.dialog.labeledElement.prototype
-		= CKEDITOR.ui.dialog.html.prototype = new CKEDITOR.ui.dialog.uiElement;
+		= CKEDITOR.ui.dialog.html.prototype
+		= new CKEDITOR.ui.dialog.uiElement;
 
 	CKEDITOR.ui.dialog.button.prototype = CKEDITOR.tools.extend( new CKEDITOR.ui.dialog.uiElement,
@@ -633,4 +691,20 @@
 			}, commonPrototype, true );
 
+	CKEDITOR.ui.dialog.file.prototype = CKEDITOR.tools.extend( new CKEDITOR.ui.dialog.labeledElement,
+			{
+				getElement : function()
+				{
+					return new CKEDITOR.dom.element( CKEDITOR.document.getById( this._.frameId )
+						.$.contentWindow.document.forms[0].elements[0] );
+				},
+
+				submit : function()
+				{
+					return this.getElement().getParent().$.submit();
+				}
+			}, true );
+
+	CKEDITOR.ui.dialog.fileButton.prototype = new CKEDITOR.ui.dialog.button;
+
 	CKEDITOR.ui.dialog.button._ = { activeButton : null };
 
@@ -641,4 +715,6 @@
 	CKEDITOR.dialog.addUIElement( 'button', commonBuilder );
 	CKEDITOR.dialog.addUIElement( 'select', commonBuilder );
+	CKEDITOR.dialog.addUIElement( 'file', commonBuilder );
+	CKEDITOR.dialog.addUIElement( 'fileButton', commonBuilder );
 	CKEDITOR.dialog.addUIElement( 'html', commonBuilder );
 })();
Index: /CKEditor/branches/prototype/_source/plugins/link/plugin.js
===================================================================
--- /CKEditor/branches/prototype/_source/plugins/link/plugin.js	(revision 2659)
+++ /CKEditor/branches/prototype/_source/plugins/link/plugin.js	(revision 2660)
@@ -308,7 +308,19 @@
 					id : 'Upload',
 					label : editor.lang.linkUpload,
-					expand : true,
 					elements : 
 					[
+						{
+							type : 'file',
+							id : 'upload',
+							label : 'Upload',
+							action : 'nowhere.php',
+							size : 38
+						},
+						{
+							type : 'fileButton',
+							id : 'uploadButton',
+							label : 'Send it to the Server',
+							'for' : [ 'Upload', 'upload' ]
+						}
 					]
 				},
Index: /CKEditor/branches/prototype/_source/skins/default/dialog.css
===================================================================
--- /CKEditor/branches/prototype/_source/skins/default/dialog.css	(revision 2659)
+++ /CKEditor/branches/prototype/_source/skins/default/dialog.css	(revision 2660)
@@ -485,8 +485,14 @@
 }
 
-.cke_skin_default .cke_dialog_ui_select_input
+.cke_skin_default .cke_dialog_ui_input_select
 {
 	border: 1px solid #a0a0a0;
 	background-color: white;
+}
+
+.cke_skin_default .cke_dialog_ui_input_file
+{
+	width: 100%;
+	height: 25px;
 }
 
