diff options
author | Thomas Müller <thomas.mueller@tmit.eu> | 2014-04-15 21:39:32 +0200 |
---|---|---|
committer | Thomas Müller <thomas.mueller@tmit.eu> | 2014-04-15 21:39:32 +0200 |
commit | 8bc7174bdca5ae7f4ea71eeb7daec56fb262a263 (patch) | |
tree | ba24da220070eb95a57708e54f2e1b4b180b3983 /apps/files/js/file-upload.js | |
parent | 7f4fefd7ad668086dde57ac7f13ed5d7b12ef862 (diff) | |
parent | 83e8981e246384de3b9d206a5dcf1109ce421005 (diff) | |
download | nextcloud-server-8bc7174bdca5ae7f4ea71eeb7daec56fb262a263.tar.gz nextcloud-server-8bc7174bdca5ae7f4ea71eeb7daec56fb262a263.zip |
Merge pull request #8104 from owncloud/lukepolo-master
Added the ability to Drag and Drop folders [chrome]
Diffstat (limited to 'apps/files/js/file-upload.js')
-rw-r--r-- | apps/files/js/file-upload.js | 26 |
1 files changed, 20 insertions, 6 deletions
diff --git a/apps/files/js/file-upload.js b/apps/files/js/file-upload.js index e5d1eacbd14..3879aa65888 100644 --- a/apps/files/js/file-upload.js +++ b/apps/files/js/file-upload.js @@ -242,11 +242,19 @@ OC.Upload = { data.errorThrown = errorMessage; } - if (file.type === '' && file.size === 4096) { - data.textStatus = 'dirorzero'; - data.errorThrown = t('files', 'Unable to upload {filename} as it is a directory or has 0 bytes', - {filename: file.name} - ); + // in case folder drag and drop is not supported file will point to a directory + // http://stackoverflow.com/a/20448357 + if (!file.type && file.size%4096 === 0 && file.size <= 102400) { + try { + reader = new FileReader(); + reader.readAsBinaryString(f); + } catch (NS_ERROR_FILE_ACCESS_DENIED) { + //file is a directory + data.textStatus = 'dirorzero'; + data.errorThrown = t('files', 'Unable to upload {filename} as it is a directory or has 0 bytes', + {filename: file.name} + ); + } } // add size @@ -326,10 +334,15 @@ OC.Upload = { submit: function(e, data) { OC.Upload.rememberUpload(data); if ( ! data.formData ) { + var fileDirectory = ''; + if(typeof data.files[0].relativePath !== 'undefined') { + fileDirectory = data.files[0].relativePath; + } // noone set update parameters, we set the minimum data.formData = { requesttoken: oc_requesttoken, - dir: $('#dir').val() + dir: $('#dir').val(), + file_directory: fileDirectory }; } }, @@ -683,3 +696,4 @@ $(document).ready(function() { OC.Upload.init(); }); + |