Index: umc/widgets/MultiUploader.js =================================================================== --- umc/widgets/MultiUploader.js (Revision 59559) +++ umc/widgets/MultiUploader.js (Arbeitskopie) @@ -88,6 +88,9 @@ // internal reference to the current Uploader widget _uploader: null, + // allow selecting of Multiple Files + multiFile: false, + // internal reference to the progress bar _progressBar: null, @@ -232,6 +235,7 @@ command: this.command, dynamicOptions: this.dynamicOptions, maxSize: this.maxSize, + multiFile: this.multiFile, canUpload: this.canUpload, style: 'float: left;' }); Index: umc/widgets/Uploader.js =================================================================== --- umc/widgets/Uploader.js (Revision 59559) +++ umc/widgets/Uploader.js (Arbeitskopie) @@ -87,6 +87,9 @@ // A size limit for the uploaded file. maxSize: 524288, + //toggle mutliple files selectable + multiFile: false, + // make sure that no sizeClass is being set sizeClass: null, @@ -124,6 +127,7 @@ this._uploader = new dojox.form.Uploader({ url: '/umcp/upload' + (this.command ? '/' + this.command : ''), label: this.buttonLabel, + multiple: this.multiFile, getForm: function() { // make sure that the Uploader does not find any of our encapsulating forms return null; @@ -150,8 +154,8 @@ this.inherited(arguments); // as soon as the user has selected a file, start the upload - this._uploader.on('change', lang.hitch(this, function(data) { - var allOk = array.every(data, function(ifile) { + this._uploader.on('change', lang.hitch(this, function(_data) { + var allOk = array.every(_data, function(ifile) { return ifile.size <= this.maxSize; }, this); if (!allOk) { @@ -159,7 +163,11 @@ this._uploader.reset(); } else { - when(this.canUpload(data[0]), lang.hitch(this, function(doUpload) { + var data = _data; + if (data.length == 1){ + data = data[0]; + } + when(this.canUpload(data), lang.hitch(this, function(doUpload) { if (!doUpload) { // upload canceled this._uploader.reset(); @@ -182,7 +190,7 @@ }); this._uploader.upload(params); this._updateLabel(); - this.onUploadStarted(data[0]); + this.onUploadStarted(data); })); } })); Index: univention-management-console-web-server =================================================================== --- univention-management-console-web-server (Revision 59559) +++ univention-management-console-web-server (Arbeitskopie) @@ -631,35 +631,54 @@ global _upload_manager req = umcp.Request('UPLOAD', arguments=[path]) + self._log('info', '##### raw request: %r' % (req, )) + options = [] body = {} - for iid, ifield in args.iteritems(): - if isinstance(ifield, cherrypy._cpreqbody.Part): - # field is a FieldStorage object - store = ifield - tmpfile = _upload_manager.add(req.id, store) - # check if filesize is allowed - st = os.stat(tmpfile) - max_size = int(configRegistry.get('umc/server/upload/max', 64)) * 1024 - if st.st_size > max_size: - self._log('warn', 'file of size %d could not be uploaded' % (st.st_size)) - raise cherrypy.HTTPError(httplib.BAD_REQUEST, 'The size of the uploaded file is too large') + def _check_field_storage(iid, ifield): + # field is a FieldStorage object + store = ifield + tmpfile = _upload_manager.add(req.id, store) - # check if enough free space is available - min_size = int(configRegistry.get('umc/server/upload/min_free_space', 51200)) # kilobyte - s = os.statvfs(tmpfile) - free_disk_space = s.f_bavail * s.f_frsize / 1024 # kilobyte - if free_disk_space < min_size: - self._log('error', 'there is not enough free space to upload files') - raise cherrypy.HTTPError(httplib.BAD_REQUEST, 'There is not enough free space on disk') + # check if filesize is allowed + st = os.stat(tmpfile) + max_size = int(configRegistry.get('umc/server/upload/max', 64)) * 1024 + if st.st_size > max_size: + self._log('warn', 'file of size %d could not be uploaded' % (st.st_size)) + raise cherrypy.HTTPError(httplib.BAD_REQUEST, 'The size of the uploaded file is too large') - filename = store.filename - # some security - for c in ('<>/'): - filename = filename.replace(c, '_') + # check if enough free space is available + min_size = int(configRegistry.get('umc/server/upload/min_free_space', 51200)) # kilobyte + s = os.statvfs(tmpfile) + free_disk_space = s.f_bavail * s.f_frsize / 1024 # kilobyte + if free_disk_space < min_size: + self._log('error', 'there is not enough free space to upload files') + raise cherrypy.HTTPError(httplib.BAD_REQUEST, 'There is not enough free space on disk') - options.append({'filename': filename, 'name': store.name, 'tmpfile': tmpfile}) + filename = store.filename + # some security + for c in ('<>/'): + filename = filename.replace(c, '_') + + options.append({'filename': filename, 'name': store.name, 'tmpfile': tmpfile}) + + + for iid, ifield in args.iteritems(): + self._log('info','###### iid, ifield: %r ; %r' % (iid, ifield, )) + if isinstance(ifield, cherrypy._cpreqbody.Part): + self._log('info', '### One File for upload') + _check_field_storage(iid, ifield) + elif isinstance(ifield, list): + self._log('info', '### Several Files for upload') + self._log('info', '### ifield: %r' % (ifield, )) + for jfield in ifield: + self._log('info', '### jfield: %r' % (jfield, )) + if isinstance(jfield, cherrypy._cpreqbody.Part): + _check_field_storage(iid, jfield) + else: + # we cannot handle any other type + CORE.warn('Unknown type of multipart/form entry: %s=%s' % (iid, ifield)) elif isinstance(ifield, basestring): # field is a string :) body[iid] = ifield @@ -684,6 +703,8 @@ response = self.get_response(sessionid, path, kwargs) + self._log('info','#### response %r' % (response, )) + # check if the request is a iframe upload if 'iframe' in kwargs and (kwargs['iframe'] not in ('false', False, 0, '0')): # this is a workaround to make iframe uploads work, they need the textarea field