aboutsummaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
Diffstat (limited to 'apps')
-rw-r--r--apps/files/ajax/delete.php16
-rw-r--r--apps/files/ajax/upload.php37
-rw-r--r--apps/files/index.php8
-rw-r--r--apps/files/js/files.js26
4 files changed, 70 insertions, 17 deletions
diff --git a/apps/files/ajax/delete.php b/apps/files/ajax/delete.php
index 6532b76df21..bb1f3fff87b 100644
--- a/apps/files/ajax/delete.php
+++ b/apps/files/ajax/delete.php
@@ -21,8 +21,20 @@ foreach($files as $file) {
}
}
+// updated max file size after upload
+$l=new OC_L10N('files');
+$maxUploadFilesize=OCP\Util::maxUploadFilesize($dir);
+$maxHumanFilesize=OCP\Util::humanFileSize($maxUploadFilesize);
+$maxHumanFilesize=$l->t('Upload') . ' max. '.$maxHumanFilesize;
+
if($success) {
- OCP\JSON::success(array("data" => array( "dir" => $dir, "files" => $files )));
+ OCP\JSON::success(array("data" => array( "dir" => $dir, "files" => $files,
+ 'uploadMaxFilesize'=>$maxUploadFilesize,
+ 'maxHumanFilesize'=>$maxHumanFilesize
+ )));
} else {
- OCP\JSON::error(array("data" => array( "message" => "Could not delete:\n" . $filesWithError )));
+ OCP\JSON::error(array("data" => array( "message" => "Could not delete:\n" . $filesWithError,
+ 'uploadMaxFilesize'=>$maxUploadFilesize,
+ 'maxHumanFilesize'=>$maxHumanFilesize
+ )));
}
diff --git a/apps/files/ajax/upload.php b/apps/files/ajax/upload.php
index 2a2d935da6c..35463095988 100644
--- a/apps/files/ajax/upload.php
+++ b/apps/files/ajax/upload.php
@@ -10,8 +10,17 @@ OCP\JSON::checkLoggedIn();
OCP\JSON::callCheck();
$l=OC_L10N::get('files');
+// 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' => $l->t( 'No file was uploaded. Unknown error' ))));
+ OCP\JSON::error(array('data' => array( 'message' => $l->t( 'No file was uploaded. Unknown error' ),
+ 'uploadMaxFilesize'=>$maxUploadFilesize,
+ 'maxHumanFilesize'=>$maxHumanFilesize
+ )));
exit();
}
@@ -28,7 +37,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();
}
}
@@ -42,7 +54,9 @@ foreach($files['size'] as $size) {
$totalSize+=$size;
}
if($totalSize>OC_Filesystem::free_space($dir)) {
- OCP\JSON::error(array('data' => array( 'message' => $l->t( 'Not enough space available' ))));
+ OCP\JSON::error(array('data' => array( 'message' => $l->t( 'Not enough space available' ),
+ 'uploadMaxFilesize'=>$maxUploadFilesize,
+ 'maxHumanFilesize'=>$maxHumanFilesize)));
exit();
}
@@ -56,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);
@@ -69,4 +91,7 @@ if(strpos($dir, '..') === false) {
$error=$l->t( 'Invalid directory.' );
}
-OCP\JSON::error(array('data' => array('message' => $error )));
+OCP\JSON::error(array('data' => array('message' => $error,
+ 'uploadMaxFilesize'=>$maxUploadFilesize,
+ 'maxHumanFilesize'=>$maxHumanFilesize
+)));
diff --git a/apps/files/index.php b/apps/files/index.php
index b64bde44cc0..8b92bcc3728 100644
--- a/apps/files/index.php
+++ b/apps/files/index.php
@@ -79,13 +79,7 @@ $breadcrumbNav = new OCP\Template('files', 'part.breadcrumb', '');
$breadcrumbNav->assign('breadcrumb', $breadcrumb, false);
$breadcrumbNav->assign('baseURL', OCP\Util::linkTo('files', 'index.php') . '?dir=', false);
-$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);
-$maxUploadFilesize = min($maxUploadFilesize, $freeSpace);
+$maxUploadFilesize=OCP\Util::maxUploadFilesize($dir);
$permissions = OCP\PERMISSION_READ;
if (OC_Filesystem::isUpdatable($dir . '/')) {
diff --git a/apps/files/js/files.js b/apps/files/js/files.js
index bb298431e84..96b3cc5b627 100644
--- a/apps/files/js/files.js
+++ b/apps/files/js/files.js
@@ -26,6 +26,23 @@ Files={
});
procesSelection();
},
+ updateMaxUploadFilesize:function(response) {
+ if(response == undefined) {
+ return;
+ }
+ if(response.data !== undefined && response.data.uploadMaxFilesize !== undefined) {
+ $('#max_upload').val(response.data.uploadMaxFilesize);
+ $('#data-upload-form a').attr('original-title', response.data.maxHumanFilesize);
+ }
+ if(response[0] == undefined) {
+ return;
+ }
+ if(response[0].uploadMaxFilesize !== undefined) {
+ $('#max_upload').val(response[0].uploadMaxFilesize);
+ $('#data-upload-form a').attr('original-title', response[0].maxHumanFilesize);
+ }
+
+ },
isFileNameValid:function (name) {
if (name === '.') {
$('#notification').text(t('files', '\'.\' is an invalid file name.'));
@@ -316,6 +333,7 @@ $(document).ready(function() {
$('#notification').text(t('files', response.data.message));
$('#notification').fadeIn();
}
+ Files.updateMaxUploadFilesize(response);
var file=response[0];
// TODO: this doesn't work if the file name has been changed server side
delete uploadingFiles[dirName][file.name];
@@ -368,7 +386,9 @@ $(document).ready(function() {
.success(function(result, textStatus, jqXHR) {
var response;
response=jQuery.parseJSON(result);
- if(response[0] != undefined && response[0].status == 'success') {
+ Files.updateMaxUploadFilesize(response);
+
+ if(response[0] != undefined && response[0].status == 'success') {
var file=response[0];
delete uploadingFiles[file.name];
$('tr').filterAttr('data-file',file.name).data('mime',file.mime).data('id',file.id);
@@ -401,7 +421,8 @@ $(document).ready(function() {
data.submit().success(function(data, status) {
// in safari data is a string
response = jQuery.parseJSON(typeof data === 'string' ? data : data[0].body.innerText);
- if(response[0] != undefined && response[0].status == 'success') {
+ Files.updateMaxUploadFilesize(response);
+ if(response[0] != undefined && response[0].status == 'success') {
var file=response[0];
delete uploadingFiles[file.name];
$('tr').filterAttr('data-file',file.name).data('mime',file.mime).data('id',file.id);
@@ -740,6 +761,7 @@ scanFiles.scanning=false;
function boolOperationFinished(data, callback) {
result = jQuery.parseJSON(data.responseText);
+ Files.updateMaxUploadFilesize(result);
if(result.status == 'success'){
callback.call();
} else {