Index: /trunk/phpgwapi/inc/class.vfs_sql.inc.php
===================================================================
--- /trunk/phpgwapi/inc/class.vfs_sql.inc.php	(revision 1648)
+++ /trunk/phpgwapi/inc/class.vfs_sql.inc.php	(revision 1693)
@@ -2391,6 +2391,4 @@
 				return False;
 			}
-			// INSERT INTO phpgw_vfs_quota values('/home/amuller',200);
-			//
 			return $GLOBALS['phpgw']->db->query("INSERT INTO phpgw_vfs_quota VALUES ('".$data['string']."',".$data['new_quota'].");", __LINE__,__FILE__);
 		}
Index: /sandbox/filemanager/setup/phpgw_pt-br.lang
===================================================================
--- /sandbox/filemanager/setup/phpgw_pt-br.lang	(revision 1678)
+++ /sandbox/filemanager/setup/phpgw_pt-br.lang	(revision 1693)
@@ -27,5 +27,6 @@
 created %1	filemanager	pt-br	Criado %1
 You have no permission to access this file	filemanager	pt-br	Você não tem permissão para acessar este arquivo
-The file sent was considered infected	filemanager	pt-br	O arquivo enviado foi considerado infectado por vírus
+The file %1 sent was considered infected	filemanager	pt-bt	o arquivo (%1) enviado foi considerado infectado por vírus
+Note: Uploaded is limited to %1MB	filemanager	pt-br	Nota: O tamanho máximo de envio é limitado a %1MB
 no comments	filemanager	pt-br	sem comentários
 created %1,%2	filemanager	pt-br	Criado %1, %2
Index: /sandbox/filemanager/inc/class.vfs_functions.inc.php
===================================================================
--- /sandbox/filemanager/inc/class.vfs_functions.inc.php	(revision 1654)
+++ /sandbox/filemanager/inc/class.vfs_functions.inc.php	(revision 1693)
@@ -216,14 +216,13 @@
 		function download()
 		{
-			for($i = 0; $i != $this->numoffiles; $i++)
-			{
-				if(!$this->fileman[$i])
-				{
-					continue;
-				}
-
-				$download_browser = CreateObject('phpgwapi.browser');
-				$download_browser->content_header($this->fileman[$i]);
-				echo $this->bo->vfs->read(array('string' => $this->fileman[$i]));
+			if($this->file)
+			{
+				//$GLOBALS['phpgw']->browser->content_header($this->file);
+				header ("Content-Type: application/octet-stream");
+				header("Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0");
+				header("Pragma: public");
+				header("Expires: 0");
+				header ("Content-Disposition: attachment; filename=\"". addslashes($this->file)."\"");
+				echo $this->bo->vfs->read(array('string' => $this->file));
 				$GLOBALS['phpgw']->common->phpgw_exit();
 			}
Index: /sandbox/filemanager/inc/class.uifilemanager.inc.php
===================================================================
--- /sandbox/filemanager/inc/class.uifilemanager.inc.php	(revision 1678)
+++ /sandbox/filemanager/inc/class.uifilemanager.inc.php	(revision 1693)
@@ -28,4 +28,5 @@
 			'edit' => True,
 			'fileModels'=>True,
+			'getReturnExecuteForm' => True,
 			'uploadModel'=>True
 		);
@@ -70,7 +71,5 @@
 		var $edit_save_done_x;
 		var $edit_cancel_x;
-		var $comment_files;
 		var $upload_x;
-		var $uploadprocess;
 
 		// this ones must be checked thorougly;
@@ -125,5 +124,4 @@
 				'sortby'	=> array('sortby' => ''),
 				'messages'	=> array('messages'	=> ''),
-				'comment_files'	=> array('comment_files' => ''),
 				'show_upload_boxes'	=> array('show_upload_boxes' => '')
 			);
@@ -163,5 +161,5 @@
 			$pref = CreateObject('phpgwapi.preferences', $this->bo->userinfo['username']);
 			$pref->read_repository();
-			//			$GLOBALS['phpgw']->hooks->single('add_def_pref', $GLOBALS['appname']);
+			//$GLOBALS['phpgw']->hooks->single('add_def_pref', $GLOBALS['appname']);
 			$pref->save_repository(True);
 			$pref_array = $pref->read_repository();
@@ -246,6 +244,7 @@
 					// FIXME we just created a fresh home dir so we know there nothing in it so we have to remove all existing content
 				}
-			}
-			
+
+
+			}
 			
 		}
@@ -526,8 +525,4 @@
 				$this->createdir();
 			}
-			elseif($this->uploadprocess)
-			{
-				$this->fileUpload();
-			}
 			elseif($this->upload_x || $this->show_upload_boxes)
 			{
@@ -739,4 +734,5 @@
 							$icon=$this->mime_icon($files['mime_type']);
 							$link=$this->encode_href('/index.php','menuaction=filemanager.uifilemanager.view','file='.$files['name'].'&path='.$this->path);
+							//$link=$this->encode_href('inc/download.php','file='.base64_encode($files['name']).'&path='.base64_encode($this->path));
 
 							$col_data='<a href="'.$link.'" target="'.$this->target.'">'.$icon.'</a>&nbsp;'.
@@ -1103,134 +1099,4 @@
 
 
-		// move to bo
-		# Handle File Uploads
-		function fileUpload()
-		{
-			if($this->path != '/' && $this->path != $this->bo->fakebase)
-			{
-				for($i = 0; $i != $this->show_upload_boxes; $i++)
-				{
-					if($badchar = $this->bo->bad_chars($_FILES['upload_file']['name'][$i], True, True))
-					{
-						$this->messages[]=lang('Error:').lang('File names cannot contain "%1"', $badchar);
-
-						continue;
-					}
-
-					# Check to see if the file exists in the database, and get its info at the same time
-					$ls_array = $this->bo->vfs->ls(array(
-						'string'=> $this->path . '/' . $_FILES['upload_file']['name'][$i],
-						'relatives'	=> array(RELATIVE_NONE),
-						'checksubdirs'	=> False,
-						'nofiles'	=> True
-					));
-
-					$fileinfo = $ls_array[0];
-
-					if($fileinfo['name'])
-					{
-						if($fileinfo['mime_type'] == 'Directory')
-						{
-							$this->messages[]= lang('Error:').lang('Cannot replace %1 because it is a directory', $fileinfo['name']);
-							continue;
-						}
-					}
-					 $max_size = $this->current_config['filemanager_Max_file_size'];
-					 if (! $max_size)
-						 $max_size = ini_get('upload_max_filesize');
-					 else
-						 $max_size .= "M";
-
-					$upload_max_filesize = str_replace("M","",$max_size) * 1024 * 1024;
-
-					if ($_FILES['upload_file']['size'][$i] > $upload_max_filesize)
-					{
-						$this->messages[]=lang('The size of %1 has exceded the limit: %2', $this->disppath.'/'.$_FILES['upload_file']['name'][$i], $max_size);
-					}
-					else if(strlen($this->current_config['filemanager_antivirus_command']) > 0)
-					{
-						$command = "nice -n19 ".$this->current_config['filemanager_antivirus_command']." ".$_FILES['upload_file']['tmp_name'][$i];
-						exec("bash -c ".escapeshellcmd(escapeshellarg($command)),$output,$return);
-						if ($return == 1)
-						{
-							$this->messages[]=lang('Error:').lang('The file sent was considered infected');
-							$this->readFilesInfo();
-			                                $this->filelisting();
-							return true;
-						}
-					}
-					if($_FILES['upload_file']['size'][$i] > 0)
-					{
-						if($fileinfo['name'] && $fileinfo['deleteable'] != 'N')
-						{
-							$tmp_arr=array(
-								'string'=> $_FILES['upload_file']['name'][$i],
-								'relatives'	=> array(RELATIVE_ALL),
-								'attributes'	=> array(
-									'owner_id' => $this->bo->userinfo['username'],
-									'modifiedby_id' => $this->bo->userinfo['username'],
-									'modified' => $this->now,
-									'size' => $_FILES['upload_file']['size'][$i],
-									'mime_type' => $_FILES['upload_file']['type'][$i],
-									'deleteable' => 'Y',
-									'comment' => stripslashes($_POST['upload_comment'][$i])
-								)
-							);
-							$this->bo->vfs->set_attributes($tmp_arr);
-
-							$tmp_arr=array(
-								'from'	=> $_FILES['upload_file']['tmp_name'][$i],
-								'to'	=> lang('new')."_".$_FILES['upload_file']['name'][$i],
-								'relatives'	=> array(RELATIVE_NONE|VFS_REAL, RELATIVE_ALL)
-							);
-							$this->bo->vfs->cp($tmp_arr);
-
-							$this->messages[]=lang('Created new %1', $this->disppath.'/'.$_FILES['upload_file']['name'][$i]);
-						}
-						else
-						{
-
-							$this->bo->vfs->cp(array(
-								'from'=> $_FILES['upload_file']['tmp_name'][$i],
-								'to'=> $_FILES['upload_file']['name'][$i],
-								'relatives'	=> array(RELATIVE_NONE|VFS_REAL, RELATIVE_ALL)
-							));
-
-							$this->bo->vfs->set_attributes(array(
-								'string'=> $_FILES['upload_file']['name'][$i],
-								'relatives'	=> array(RELATIVE_ALL),
-								'attributes'=> array(
-									'mime_type' => $_FILES['upload_file']['type'][$i],
-									'comment' => stripslashes($_POST['upload_comment'][$i])
-								)
-							));
-
-							$this->messages[]=lang('Created %1,%2', $this->disppath.'/'.$_FILES['upload_file']['name'][$i], $_FILES['upload_file']['size'][$i]);
-						}
-					}
-					elseif($_FILES['upload_file']['name'][$i])
-					{
-						$this->bo->vfs->touch(array(
-							'string'=> $_FILES['upload_file']['name'][$i],
-							'relatives'	=> array(RELATIVE_ALL)
-						));
-
-						$this->bo->vfs->set_attributes(array(
-							'string'=> $_FILES['upload_file']['name'][$i],
-							'relatives'	=> array(RELATIVE_ALL),
-							'attributes'=> array(
-								'mime_type' => $_FILES['upload_file']['type'][$i],
-								'comment' => stripslashes($_POST['upload_comment'][$i])
-							)
-						));
-
-						$this->messages[]=lang('Created %1,%2', $this->disppath.'/'.$_FILES['upload_file']['name'][$i], $file_size[$i]);
-					}
-				}
-
-				$this->readFilesInfo();
-				$this->filelisting();
-			}
-		}
 		# Handle Moving Files and Directories
 		function moveTo()
@@ -1359,4 +1225,10 @@
 			}
 		}
+		function getReturnExecuteForm(){
+			$response = $_SESSION['response'];
+			$_SESSION['response'] = null;
+			echo $response;
+			return;
+		}
 		function showUploadboxes()
 		{
@@ -1368,5 +1240,7 @@
 			if($this->path != '/' && $this->path != $this->bo->fakebase && $this->can_add)
 			{
-				$vars[form_action]=$GLOBALS[phpgw]->link('/index.php','menuaction=filemanager.uifilemanager.index');
+				$vars[max_size]=lang('Note: Uploaded is limited to %1MB',($this->current_config['filemanager_Max_file_size']));
+				$vars[form_action]=$GLOBALS[phpgw]->link('/filemanager/inc/upload.php');
+				//$vars[form_action]=$GLOBALS[phpgw]->link('/index.php','menuaction=filemanager.uifilemanager.index');
 				$vars[path]=$this->path;
 				$vars[lang_file]=lang('File');
@@ -1653,5 +1527,9 @@
 					'nofiles'	=> True
 				));
-
+				if ($ls_array[0]['size'] > 4194304){
+					header('Location:'.$this->encode_href('inc/download.php','file='.base64_encode($this->file).'&path='.base64_encode($this->path)));
+					return;
+				}
+				$_SESSION['debug'][] = $ls_array;
 				if($ls_array[0]['mime_type'])
 				{
@@ -1666,5 +1544,5 @@
 				if(in_array($mime_type,$viewable))
 				{
-	   				
+					/*Note: if you put application/octet-stream you force download */
 					header('Content-type: ' . $mime_type);
 					header('Content-disposition: filename="' . $this->file . '"');//FIXME
@@ -1675,4 +1553,6 @@
 					$GLOBALS['phpgw']->browser->content_header($this->file,$mime_type);//FIXME
 				}
+ 
+
 				echo $this->bo->vfs->read(array(
 					'string'	=> $this->path.'/'.$this->file,//FIXME
Index: /sandbox/filemanager/inc/upload.php
===================================================================
--- /sandbox/filemanager/inc/upload.php	(revision 1693)
+++ /sandbox/filemanager/inc/upload.php	(revision 1693)
@@ -0,0 +1,134 @@
+<?php
+require_once '../../header.session.inc.php';
+
+/* This single file is used to increase upload_max_filesize and post_max_size using .htaccess*/
+if(!isset($GLOBALS['phpgw_info'])){
+	$GLOBALS['phpgw_info']['flags'] = array(
+		'currentapp' => 'filemanager',
+		'nonavbar'   => true,
+		'noheader'   => true
+	);
+}
+require_once '../../header.inc.php';
+
+$bo = CreateObject('filemanager.bofilemanager');
+
+$c = CreateObject('phpgwapi.config','filemanager');
+$c->read_repository();
+$current_config = $c->config_data;
+$upload_max_size = $current_config['filemanager_Max_file_size'];
+$path = base64_decode($_POST['path']);
+$show_upload_boxes = $_POST['show_upload_boxes'];
+
+if($path != '/')
+	for($i = 0; $i != $show_upload_boxes; $i++)
+	{
+		if($badchar = $bo->bad_chars($_FILES['upload_file']['name'][$i], True, True))
+		{
+			$_SESSION['response'] = lang('Error:').lang('File names cannot contain "%1"', $badchar);
+			return;
+		}
+
+		# Check to see if the file exists in the database, and get its info at the same time
+		$ls_array = $bo->vfs->ls(array(
+			'string'=> $path . '/' . $_FILES['upload_file']['name'][$i],
+			'relatives'	=> array(RELATIVE_NONE),
+			'checksubdirs'	=> False,
+			'nofiles'	=> True
+		));
+
+		$fileinfo = $ls_array[0];
+
+		if($fileinfo['name'])
+		{
+			if($fileinfo['mime_type'] == 'Directory')
+			{
+				$_SESSION['response'] = lang('Error:').lang('Cannot replace %1 because it is a directory', $fileinfo['name']);
+				return;
+			}
+		}
+
+		if ($_FILES['upload_file']['size'][$i] > ($upload_max_size*1024*1024))
+		{
+			$_SESSION['response'] = lang('The size of %1 has exceded the limit: %2', $_FILES['upload_file']['name'][$i], $upload_max_size);
+			return;
+		}
+		else if(strlen($current_config['filemanager_antivirus_command']) > 0)
+		{
+			$command = "nice -n19 ".$current_config['filemanager_antivirus_command']." ".$_FILES['upload_file']['tmp_name'][$i];
+			exec("bash -c ".escapeshellcmd(escapeshellarg($command)),$output,$return);
+			if ($return == 1)
+			{
+				 $_SESSION['response'] = lang('Error:').lang('The file %1 sent was considered infected',$_FILES['upload_file']['name'][$i]);
+				return;
+			}
+		}
+		if($_FILES['upload_file']['size'][$i] > 0)
+		{
+			if($fileinfo['name'] && $fileinfo['deleteable'] != 'N')
+			{
+				$tmp_arr=array(
+					'string'=> $_FILES['upload_file']['name'][$i],
+					'relatives'	=> array(RELATIVE_ALL),
+					'attributes'	=> array(
+						'owner_id' => $bo->userinfo['username'],
+						'modifiedby_id' => $bo->userinfo['username'],
+						'modified' => $now,
+						'size' => $_FILES['upload_file']['size'][$i],
+						'mime_type' => $_FILES['upload_file']['type'][$i],
+						'deleteable' => 'Y',
+						'comment' => stripslashes($_POST['upload_comment'][$i])
+					)
+				);
+				$bo->vfs->set_attributes($tmp_arr);
+
+				$tmp_arr=array(
+					'from'	=> $_FILES['upload_file']['tmp_name'][$i],
+					'to'	=> lang('new')."_".$_FILES['upload_file']['name'][$i],
+					'relatives'	=> array(RELATIVE_NONE|VFS_REAL, RELATIVE_ALL)
+				);
+				$bo->vfs->cp($tmp_arr);
+
+				 $_SESSION['response'] .= lang('Created new %1', $_FILES['upload_file']['name'][$i])."\n";
+			}
+			else
+			{
+
+				$bo->vfs->cp(array(
+					'from'=> $_FILES['upload_file']['tmp_name'][$i],
+					'to'=> $_FILES['upload_file']['name'][$i],
+					'relatives'	=> array(RELATIVE_NONE|VFS_REAL, RELATIVE_ALL)
+				));
+
+				$bo->vfs->set_attributes(array(
+					'string'=> $_FILES['upload_file']['name'][$i],
+					'relatives'	=> array(RELATIVE_ALL),
+					'attributes'=> array(
+						'mime_type' => $_FILES['upload_file']['type'][$i],
+						'comment' => stripslashes($_POST['upload_comment'][$i])
+					)
+				));
+
+				 $_SESSION['response'] .= lang('Created %1,%2', $_FILES['upload_file']['name'][$i], $_FILES['upload_file']['size'][$i])."\n";
+			}
+		}
+		elseif($_FILES['upload_file']['name'][$i])
+		{
+			$bo->vfs->touch(array(
+				'string'=> $_FILES['upload_file']['name'][$i],
+				'relatives'	=> array(RELATIVE_ALL)
+			));
+
+			$bo->vfs->set_attributes(array(
+				'string'=> $_FILES['upload_file']['name'][$i],
+				'relatives'	=> array(RELATIVE_ALL),
+				'attributes'=> array(
+					'mime_type' => $_FILES['upload_file']['type'][$i],
+					'comment' => stripslashes($_POST['upload_comment'][$i])
+				)
+			));
+
+			 $_SESSION['response'] .= lang('Created %1,%2', $_FILES['upload_file']['name'][$i], $file_size[$i])."\n";
+		}
+	}
+?>
Index: /sandbox/filemanager/inc/.htaccess
===================================================================
--- /sandbox/filemanager/inc/.htaccess	(revision 1693)
+++ /sandbox/filemanager/inc/.htaccess	(revision 1693)
@@ -0,0 +1,4 @@
+php_value post_max_size 1G
+php_value upload_max_filesize 1G
+php_value memory_limit 200M
+
Index: /sandbox/filemanager/inc/class.bofilemanager.inc.php
===================================================================
--- /sandbox/filemanager/inc/class.bofilemanager.inc.php	(revision 1506)
+++ /sandbox/filemanager/inc/class.bofilemanager.inc.php	(revision 1693)
@@ -110,6 +110,11 @@
 			if ($size < 1024)
 			$rstring = $left . $size . 'B' . $right;
-			else
-			$rstring = $left . round($size/1024) . 'KB' . $right;
+			else if ($size < 1048576)
+				$rstring = $left . round($size/1024) . 'KB' . $right;
+			else if ($size < 1073741824)
+				$rstring = $left . round($size/1024/1024) . 'MB' . $right;
+			else
+				$rstring = $left . round($size/1024/1024/1024) . 'GB' . $right;
+
 
 			return ($this->eor ($rstring, $return));
Index: /sandbox/filemanager/inc/download.php
===================================================================
--- /sandbox/filemanager/inc/download.php	(revision 1693)
+++ /sandbox/filemanager/inc/download.php	(revision 1693)
@@ -0,0 +1,27 @@
+<?php
+/* This single file is used to increase memory_limit using .htaccess*/
+if(!isset($GLOBALS['phpgw_info'])){
+	$GLOBALS['phpgw_info']['flags'] = array(
+		'currentapp' => 'filemanager',
+		'nonavbar'   => true,
+		'noheader'   => true
+	);
+}
+require_once '../../header.inc.php';
+
+$bo = CreateObject('filemanager.bofilemanager');
+$path = base64_decode($_GET['path']);
+$file = base64_decode($_GET['file']);
+
+if($file)
+{
+	//$GLOBALS['phpgw']->browser->content_header($file);
+	header ("Content-Type: application/octet-stream");
+	header("Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0");
+	header("Pragma: public");
+	header("Expires: 0");
+	header ("Content-Disposition: attachment; filename=\"". addslashes($file)."\"");
+	echo $bo->vfs->read(array('string' => $file));
+	$GLOBALS['phpgw']->common->phpgw_exit();
+}
+?>
Index: /sandbox/filemanager/js/uploadForm.js
===================================================================
--- /sandbox/filemanager/js/uploadForm.js	(revision 1627)
+++ /sandbox/filemanager/js/uploadForm.js	(revision 1693)
@@ -11,2 +11,14 @@
 	document.getElementById('show_upload_boxes').value +=1;
 }
+
+function sendFiles(){
+		cExecuteForm(document.getElementById('form_up'),handler_upload);
+		document.getElementById('button_up').style.visibility = "hidden";
+		var line = document.getElementById('uploadOption');
+		line.parentNode.innerHTML = "<img src='./filemanager/templates/default/images/progress.gif'>";
+}
+
+function handler_upload(data){
+	alert(data);
+	window.location = "/index.php?menuaction=filemanager.uifilemanager.index";
+}
Index: /sandbox/filemanager/js/connector.js
===================================================================
--- /sandbox/filemanager/js/connector.js	(revision 1590)
+++ /sandbox/filemanager/js/connector.js	(revision 1693)
@@ -96,20 +96,20 @@
 var connector = new cConnector();
 
-function cExecuteForm(url, form, handler){
+function cExecuteForm(form, handler){
 	connector.showProgressBar();
-	var iframe_el = document.getElementById('nullFrame');
-	if (!iframe_el)
-	{
-		iframe_el = document.createElement('IFRAME');
-		iframe_el.id = "nullFrame";
+	if(! (divUpload = document.getElementById('divUpload'))) {
+		divUpload               = document.createElement('DIV');                
+		divUpload.id    = 'divUpload';
+		document.body.appendChild(divUpload);
 	}
-	iframe_el.style.width = "0px";
-	iframe_el.style.height = "0px";
-	iframe_el.style.border = '0px';
-	iframe_el.name = "nullFrame";
-	iframe = document.body.appendChild(iframe_el);
-	iframe_el.setAttribute('onload', 'javascript:'+handler+'()');
-	form.target = "nullFrame";
-	form.submit();
+
+	handlerExecuteForm = handler;
+	var form_handler = function (data){
+		handlerExecuteForm(data);
+		handlerExecuteForm = null;
+	}
+	divUpload.innerHTML= "<iframe onload=\"connector.hideProgressBar();cExecute('./index.php/index.php?menuaction=filemanager.uifilemanager.getReturnExecuteForm',"+form_handler+");\"  style='display:none;width:0;height:0;' name='uploadFile'></iframe>";
+	form.target ="uploadFile";
+        form.submit();
 }
 
Index: /sandbox/filemanager/templates/default/upload.tpl
===================================================================
--- /sandbox/filemanager/templates/default/upload.tpl	(revision 1627)
+++ /sandbox/filemanager/templates/default/upload.tpl	(revision 1693)
@@ -1,5 +1,5 @@
 <!-- BEGIN upload_header -->
 <script src="filemanager/js/uploadForm.js" type="text/javascript"></script>
-<form method="post" action="{form_action}" enctype="multipart/form-data">
+<form id="form_up" method="post" action="{form_action}" enctype="multipart/form-data">
 <div>
 <table cellspacing="0" cellpadding="2">
@@ -21,8 +21,10 @@
 
 </tbody></table>
+<span>{max_size}</span>
+<br>
 <input value="true" name="uploadprocess" type="hidden">
 <input value="{path}" name="path" type="hidden">
 <input value="{num_upload_boxes}" name="show_upload_boxes" id="show_upload_boxes" type="hidden">
-<input value="{lang_upload}" name="upload_files" type="submit">
+<input value="{lang_upload}" id="button_up" type="button" onclick="sendFiles();">
 </div>
 </form>
