summaryrefslogtreecommitdiffstats
path: root/apps/files/ajax/upload.php
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 /apps/files/ajax/upload.php
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 'apps/files/ajax/upload.php')
-rw-r--r--apps/files/ajax/upload.php38
1 files changed, 32 insertions, 6 deletions
diff --git a/apps/files/ajax/upload.php b/apps/files/ajax/upload.php
index e7823bc4ffb..4a9816454d9 100644
--- a/apps/files/ajax/upload.php
+++ b/apps/files/ajax/upload.php
@@ -9,8 +9,17 @@ OCP\JSON::setContentTypeHeader('text/plain');
OCP\JSON::checkLoggedIn();
OCP\JSON::callCheck();
+// current max upload size
+$l=new OC_L10N('files');
+$maxUploadFilesize=OCP\Util::maxUploadFilesize($dir);
+$maxHumanFilesize=OCP\Util::humanFileSize($maxUploadFilesize);
+$maxHumanFilesize=$l->t('Upload') . ' max. '.$maxHumanFilesize;
+
if (!isset($_FILES['files'])) {
- OCP\JSON::error(array('data' => array( 'message' => 'No file was uploaded. Unknown error' )));
+ OCP\JSON::error(array('data' => array( 'message' => 'No file was uploaded. Unknown error',
+ 'uploadMaxFilesize'=>$maxUploadFilesize,
+ 'maxHumanFilesize'=>$maxHumanFilesize
+ )));
exit();
}
foreach ($_FILES['files']['error'] as $error) {
@@ -27,7 +36,10 @@ foreach ($_FILES['files']['error'] as $error) {
UPLOAD_ERR_NO_TMP_DIR=>$l->t('Missing a temporary folder'),
UPLOAD_ERR_CANT_WRITE=>$l->t('Failed to write to disk'),
);
- OCP\JSON::error(array('data' => array( 'message' => $errors[$error] )));
+ OCP\JSON::error(array('data' => array( 'message' => $errors[$error],
+ 'uploadMaxFilesize'=>$maxUploadFilesize,
+ 'maxHumanFilesize'=>$maxHumanFilesize
+ )));
exit();
}
}
@@ -41,7 +53,10 @@ foreach($files['size'] as $size) {
$totalSize+=$size;
}
if($totalSize>OC_Filesystem::free_space($dir)) {
- OCP\JSON::error(array('data' => array( 'message' => 'Not enough space available' )));
+ OCP\JSON::error(array('data' => array( 'message' => 'Not enough space available',
+ 'uploadMaxFilesize'=>$maxUploadFilesize,
+ 'maxHumanFilesize'=>$maxHumanFilesize
+ )));
exit();
}
@@ -55,11 +70,19 @@ if(strpos($dir, '..') === false) {
if(is_uploaded_file($files['tmp_name'][$i]) and OC_Filesystem::fromTmpFile($files['tmp_name'][$i], $target)) {
$meta = OC_FileCache::get($target);
$id = OC_FileCache::getId($target);
- $result[]=array( 'status' => 'success',
+ // updated max file size after upload
+ $maxUploadFilesize=OCP\Util::maxUploadFilesize($dir);
+ $maxHumanFilesize=OCP\Util::humanFileSize($maxUploadFilesize);
+ $maxHumanFilesize=$l->t('Upload') . ' max. '.$maxHumanFilesize;
+
+ $result[]=array( 'status' => 'success',
'mime'=>$meta['mimetype'],
'size'=>$meta['size'],
'id'=>$id,
- 'name'=>basename($target));
+ 'name'=>basename($target),
+ 'uploadMaxFilesize'=>$maxUploadFilesize,
+ 'maxHumanFilesize'=>$maxHumanFilesize
+ );
}
}
OCP\JSON::encodedPrint($result);
@@ -68,4 +91,7 @@ if(strpos($dir, '..') === false) {
$error='invalid dir';
}
-OCP\JSON::error(array('data' => array('error' => $error, 'file' => $fileName)));
+OCP\JSON::error(array('data' => array('error' => $error, 'file' => $fileName,
+ 'uploadMaxFilesize'=>$maxUploadFilesize,
+ 'maxHumanFilesize'=>$maxHumanFilesize
+)));