diff --git a/apps/files_sharing/public.php b/apps/files_sharing/public.php
index e345b91e293c0e2244c8e3a91708b60984e95280..1da972ad7e3fd295053a4b419de74cb1bdf2c501 100644
--- a/apps/files_sharing/public.php
+++ b/apps/files_sharing/public.php
@@ -141,7 +141,9 @@ if (isset($path)) {
 			OCP\Util::addscript('files', 'keyboardshortcuts');
 			$files = array();
 			$rootLength = strlen($basePath) + 1;
+			$totalSize = 0;
 			foreach (\OC\Files\Filesystem::getDirectoryContent($path) as $i) {
+				$totalSize += $i['size'];
 				$i['date'] = OCP\Util::formatDate($i['mtime']);
 				if ($i['type'] == 'file') {
 					$fileinfo = pathinfo($i['name']);
@@ -188,7 +190,9 @@ if (isset($path)) {
 			$folder->assign('allowZipDownload', intval(OCP\Config::getSystemValue('allowZipDownload', true)));
 			$folder->assign('usedSpacePercent', 0);
 			$tmpl->assign('folder', $folder->fetchPage());
-			$tmpl->assign('allowZipDownload', intval(OCP\Config::getSystemValue('allowZipDownload', true)));
+			$allowZip = OCP\Config::getSystemValue('allowZipDownload', true)
+						&& $totalSize <= OCP\Config::getSystemValue('maxZipInputSize', OCP\Util::computerFileSize('800 MB'));
+			$tmpl->assign('allowZipDownload', intval($allowZip));
 			$tmpl->assign('downloadURL',
 				OCP\Util::linkToPublic('files') . $urlLinkIdentifiers . '&download&path=' . urlencode($getPath));
 		} else {
diff --git a/lib/files.php b/lib/files.php
index 447ffb50577b07298fc034ed48471a590ff8d997..71bb21851b6f57b89c586600eb83a002e16834f0 100644
--- a/lib/files.php
+++ b/lib/files.php
@@ -219,12 +219,18 @@ class OC_Files {
 		$zipLimit = OC_Config::getValue('maxZipInputSize', OC_Helper::computerFileSize('800 MB'));
 		if ($zipLimit > 0) {
 			$totalsize = 0;
-			if (is_array($files)) {
-				foreach ($files as $file) {
-					$totalsize += \OC\Files\Filesystem::filesize($dir . '/' . $file);
+			if(!is_array($files)) {
+				$files = array($files);
+			}
+			foreach ($files as $file) {
+				$path = $dir . '/' . $file;
+				if(\OC\Files\Filesystem::is_dir($path)) {
+					foreach (\OC\Files\Filesystem::getDirectoryContent($path) as $i) {
+						$totalsize += $i['size'];
+					}
+				} else {
+					$totalsize += \OC\Files\Filesystem::filesize($path);
 				}
-			} else {
-				$totalsize += \OC\Files\Filesystem::filesize($dir . '/' . $files);
 			}
 			if ($totalsize > $zipLimit) {
 				$l = OC_L10N::get('lib');