summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorThomas Müller <thomas.mueller@tmit.eu>2013-01-18 14:06:00 -0800
committerThomas Müller <thomas.mueller@tmit.eu>2013-01-18 14:06:00 -0800
commit31cc9aa80d4284e13dc95d2ef1428bed78c22d65 (patch)
tree3b42e3a95bc0a92cd75bba16438e9dcf55f49e89 /lib
parentedf3572835ac5a6584fdde7ba7bb1faa64251e2d (diff)
parent5ff29b4348a1dcb9ed32273133b1c787aaf5c72c (diff)
downloadnextcloud-server-31cc9aa80d4284e13dc95d2ef1428bed78c22d65.tar.gz
nextcloud-server-31cc9aa80d4284e13dc95d2ef1428bed78c22d65.zip
Merge pull request #986 from owncloud/fixing-784-master
the maximum upload size is now part of the response of the upload and de...
Diffstat (limited to 'lib')
-rw-r--r--lib/helper.php21
-rw-r--r--lib/public/util.php10
2 files changed, 29 insertions, 2 deletions
diff --git a/lib/helper.php b/lib/helper.php
index 5d7e3fa4894..7be54cacbed 100644
--- a/lib/helper.php
+++ b/lib/helper.php
@@ -679,8 +679,8 @@ class OC_Helper {
$start = intval($start);
$length = intval($length);
$string = mb_substr($string, 0, $start, $encoding) .
- $replacement .
- mb_substr($string, $start+$length, mb_strlen($string, 'UTF-8')-$start, $encoding);
+ $replacement .
+ mb_substr($string, $start+$length, mb_strlen($string, 'UTF-8')-$start, $encoding);
return $string;
}
@@ -749,6 +749,23 @@ class OC_Helper {
}
/**
+ * @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);
+ }
+
+ /**
* Checks if a function is available
* @param string $function_name
* @return bool
diff --git a/lib/public/util.php b/lib/public/util.php
index 8197482c0dd..413dbcccd28 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);
+ }
}