Noded/frontend#29 - allow uploading multiple files at once
This commit is contained in:
parent
2c105fe350
commit
a59255a39b
@ -49,13 +49,17 @@ class File extends Controller {
|
|||||||
async save_upload(req, res) {
|
async save_upload(req, res) {
|
||||||
const { page, node, file_group } = req.form
|
const { page, node, file_group } = req.form
|
||||||
|
|
||||||
let file_name = ''
|
const n_files = Object.values(req.uploads).length
|
||||||
if ( req.uploads.uploaded_file ) {
|
|
||||||
file_group.FileIds.push(req.uploads.uploaded_file.id)
|
for ( const key in req.uploads ) {
|
||||||
|
if ( !req.uploads.hasOwnProperty(key) ) continue
|
||||||
|
if ( !key.startsWith('uploaded_file_') ) continue
|
||||||
|
|
||||||
|
file_group.FileIds.push(req.uploads[key].id)
|
||||||
}
|
}
|
||||||
|
|
||||||
await file_group.version_save(`Added file${file_name ? ' "'+file_name+'"' : ''}`, req.user.id)
|
await file_group.version_save(`Added ${n_files} file${n_files === 1 ? '' : 's'}`, req.user.id)
|
||||||
return res.redirect(req.body.redirectTo ? req.body.redirectTo : '/')
|
return res.api()
|
||||||
}
|
}
|
||||||
|
|
||||||
async download(req, res) {
|
async download(req, res) {
|
||||||
|
Loading…
Reference in New Issue
Block a user