summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorThomas Müller <thomas.mueller@tmit.eu>2012-12-20 17:16:01 +0100
committerThomas Müller <thomas.mueller@tmit.eu>2012-12-20 17:16:53 +0100
commit39d874cd902a4e3d4f7ae313ec5e15bafe35df13 (patch)
tree5ff19b3755fc02f6f9eecd64996094e2bed388dd /lib
parentbdc8d0098adfb0225bc4a67ab72344a203448e34 (diff)
downloadnextcloud-server-39d874cd902a4e3d4f7ae313ec5e15bafe35df13.tar.gz
nextcloud-server-39d874cd902a4e3d4f7ae313ec5e15bafe35df13.zip
the maximum upload size is now part of the response of the upload and delete operation.
the maximum upload size is updated within the browser once an upload or delete operation has been finished
Diffstat (limited to 'lib')
-rw-r--r--lib/helper.php17
-rw-r--r--lib/public/util.php10
2 files changed, 27 insertions, 0 deletions
diff --git a/lib/helper.php b/lib/helper.php
index be4e4e52677..91b22e48f89 100644
--- a/lib/helper.php
+++ b/lib/helper.php
@@ -758,4 +758,21 @@ class OC_Helper {
}
return $str;
}
+
+ /**
+ * @brief calculates the maximum upload size respecting system settings, free space and user quota
+ *
+ * @param $dir the current folder where the user currently operates
+ * @return number of bytes representing
+ */
+ public static function maxUploadFilesize($dir) {
+ $upload_max_filesize = OCP\Util::computerFileSize(ini_get('upload_max_filesize'));
+ $post_max_size = OCP\Util::computerFileSize(ini_get('post_max_size'));
+ $maxUploadFilesize = min($upload_max_filesize, $post_max_size);
+
+ $freeSpace = OC_Filesystem::free_space($dir);
+ $freeSpace = max($freeSpace, 0);
+
+ return min($maxUploadFilesize, $freeSpace);
+ }
}
diff --git a/lib/public/util.php b/lib/public/util.php
index 9727cfda284..9e641c6881c 100644
--- a/lib/public/util.php
+++ b/lib/public/util.php
@@ -367,4 +367,14 @@ class Util {
public static function recursiveArraySearch($haystack, $needle, $index = null) {
return(\OC_Helper::recursiveArraySearch($haystack, $needle, $index));
}
+
+ /**
+ * @brief calculates the maximum upload size respecting system settings, free space and user quota
+ *
+ * @param $dir the current folder where the user currently operates
+ * @return number of bytes representing
+ */
+ public static function maxUploadFilesize($dir) {
+ return \OC_Helper::maxUploadFilesize($dir);
+ }
}