summaryrefslogtreecommitdiffstats
path: root/files
diff options
context:
space:
mode:
authorRobin Appelman <icewind1991@gmail.com>2010-09-06 23:09:14 +0200
committerRobin Appelman <icewind1991@gmail.com>2010-09-06 23:09:14 +0200
commit5da12fcfa13f2c3497470edc97315363aa89e47c (patch)
tree5e988c4f2f88b86493e21be03c69440052290855 /files
parentb0dbb2ac9d5f5899ea6b9cad808413aeac7292d1 (diff)
downloadnextcloud-server-5da12fcfa13f2c3497470edc97315363aa89e47c.tar.gz
nextcloud-server-5da12fcfa13f2c3497470edc97315363aa89e47c.zip
use json to encode the file list, should work better with filenames containing non-ascii characters
Diffstat (limited to 'files')
-rw-r--r--files/api.php22
1 files changed, 20 insertions, 2 deletions
diff --git a/files/api.php b/files/api.php
index d6e04d4550f..3cb796d432c 100644
--- a/files/api.php
+++ b/files/api.php
@@ -53,7 +53,10 @@ if($arguments['action']){
OC_FILES::get($arguments['dir'],$arguments['file']);
break;
case 'getfiles':
- echo json_encode(OC_FILES::getdirectorycontent($arguments['dir']));
+ $max_upload=min(return_bytes(ini_get('post_max_size')),return_bytes(ini_get('upload_max_filesize')));
+ $files=OC_FILES::getdirectorycontent($arguments['dir']);
+ $files['__max_upload']=$max_upload;
+ echo json_encode($files);
break;
case 'gettree':
echo json_encode(OC_FILES::getTree($arguments['dir']));
@@ -80,4 +83,19 @@ if($arguments['action']){
}
}
-?> \ No newline at end of file
+function return_bytes($val) {
+ $val = trim($val);
+ $last = strtolower($val[strlen($val)-1]);
+ switch($last) {
+ // The 'G' modifier is available since PHP 5.1.0
+ case 'g':
+ $val *= 1024;
+ case 'm':
+ $val *= 1024;
+ case 'k':
+ $val *= 1024;
+ }
+
+ return $val;
+}
+?>