aboutsummaryrefslogtreecommitdiffstats
path: root/apps/files/js/file-upload.js
diff options
context:
space:
mode:
authorRobin Appelman <icewind@owncloud.com>2014-02-05 13:36:55 +0100
committerRobin Appelman <icewind@owncloud.com>2014-02-05 13:36:55 +0100
commit1e79369338e8435952e2eda60a2cfc49bb6c4882 (patch)
tree12d3ac88978887f16e795c54873bbd6b99bb8ee5 /apps/files/js/file-upload.js
parent3c1ab66edac1ba2f1b398c859cd933c410ea3d8d (diff)
parent3d88b10f201b7979f250b49b10360b3581030ec7 (diff)
downloadnextcloud-server-1e79369338e8435952e2eda60a2cfc49bb6c4882.tar.gz
nextcloud-server-1e79369338e8435952e2eda60a2cfc49bb6c4882.zip
merge master into storagestatistics-reuse
Diffstat (limited to 'apps/files/js/file-upload.js')
-rw-r--r--apps/files/js/file-upload.js37
1 files changed, 34 insertions, 3 deletions
diff --git a/apps/files/js/file-upload.js b/apps/files/js/file-upload.js
index 225c3319107..f962a7044a8 100644
--- a/apps/files/js/file-upload.js
+++ b/apps/files/js/file-upload.js
@@ -1,3 +1,13 @@
+/*
+ * Copyright (c) 2014
+ *
+ * This file is licensed under the Affero General Public License version 3
+ * or later.
+ *
+ * See the COPYING-README file.
+ *
+ */
+
/**
* The file upload code uses several hooks to interact with blueimps jQuery file upload library:
* 1. the core upload handling hooks are added when initializing the plugin,
@@ -8,6 +18,8 @@
* - TODO music upload button
*/
+/* global OC, t, n */
+
/**
* Function that will allow us to know if Ajax uploads are supported
* @link https://github.com/New-Bamboo/example-ajax-upload/blob/master/public/index.html
@@ -241,10 +253,22 @@ $(document).ready(function() {
// add size
selection.totalBytes += file.size;
- //check max upload size
- if (selection.totalBytes > $('#max_upload').val()) {
+ // check PHP upload limit
+ if (selection.totalBytes > $('#upload_limit').val()) {
+ data.textStatus = 'sizeexceedlimit';
+ data.errorThrown = t('files', 'Total file size {size1} exceeds upload limit {size2}', {
+ 'size1': humanFileSize(selection.totalBytes),
+ 'size2': humanFileSize($('#upload_limit').val())
+ });
+ }
+
+ // check free space
+ if (selection.totalBytes > $('#free_space').val()) {
data.textStatus = 'notenoughspace';
- data.errorThrown = t('files', 'Not enough space available');
+ data.errorThrown = t('files', 'Not enough free space, you are uploading {size1} but only {size2} is left', {
+ 'size1': humanFileSize(selection.totalBytes),
+ 'size2': humanFileSize($('#free_space').val())
+ });
}
// end upload for whole selection on error
@@ -315,6 +339,13 @@ $(document).ready(function() {
} else {
// HTTP connection problem
OC.Notification.show(data.errorThrown);
+ if (data.result) {
+ var result = JSON.parse(data.result);
+ if (result && result[0] && result[0].data && result[0].data.code === 'targetnotfound') {
+ // abort upload of next files if any
+ OC.Upload.cancelUploads();
+ }
+ }
}
//hide notification after 10 sec
setTimeout(function() {