Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
PUBLIC
/
surfer-okd
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit ecfbca9f
authored
Nov 15, 2016
by
Johannes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Support multifile upload via the webinterface
1 parent
5be531a3
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
12 deletions
app/index.html
app/js/app.js
app/index.html
View file @
ecfbca9
...
...
@@ -108,7 +108,7 @@
<div
class=
"col-lg-12"
>
<center>
<form
id=
"fileUploadForm"
>
<input
type=
"file"
v-el:upload
style=
"display: none"
id=
"uploadInput"
/>
<input
type=
"file"
v-el:upload
style=
"display: none"
id=
"uploadInput"
multiple
/>
<button
class=
"btn btn-primary"
v-on:click
.
stop
.
prevent=
"upload()"
id=
"uploadButton"
>
Upload
</button>
</form>
</center>
...
...
app/js/app.js
View file @
ecfbca9
...
...
@@ -129,21 +129,32 @@ function upload() {
// detach event handler
$
(
app
.
$els
.
upload
).
off
(
'change'
);
var
file
=
app
.
$els
.
upload
.
files
[
0
]
;
var
path
=
encode
(
sanitize
(
app
.
path
+
'/'
+
file
.
name
))
;
var
length
=
app
.
$els
.
upload
.
files
.
length
;
var
done
=
0
;
var
formData
=
new
FormData
();
formData
.
append
(
'file'
,
file
);
function
uploadFile
(
file
)
{
var
path
=
encode
(
sanitize
(
app
.
path
+
'/'
+
file
.
name
)
);
superagent
.
put
(
'/api/files'
+
path
).
query
({
username
:
app
.
session
.
username
,
password
:
app
.
session
.
password
}).
send
(
formData
).
end
(
function
(
error
,
result
)
{
app
.
busy
=
false
;
var
formData
=
new
FormData
();
formData
.
append
(
'file'
,
file
)
;
if
(
result
&&
result
.
statusCode
===
401
)
return
logout
();
if
(
result
&&
result
.
statusCode
!==
201
)
return
console
.
error
(
'Error uploading file: '
,
result
.
statusCode
);
if
(
error
)
return
console
.
error
(
error
);
superagent
.
put
(
'/api/files'
+
path
).
query
({
username
:
app
.
session
.
username
,
password
:
app
.
session
.
password
}).
send
(
formData
).
end
(
function
(
error
,
result
)
{
if
(
result
&&
result
.
statusCode
===
401
)
return
logout
();
if
(
result
&&
result
.
statusCode
!==
201
)
console
.
error
(
'Error uploading file: '
,
result
.
statusCode
);
if
(
error
)
console
.
error
(
error
);
refresh
();
});
++
done
;
if
(
done
>=
length
)
{
app
.
busy
=
false
;
refresh
();
}
});
}
for
(
var
i
=
0
;
i
<
length
;
i
++
)
{
uploadFile
(
app
.
$els
.
upload
.
files
[
i
]);
}
});
// reset the form first to make the change handler retrigger even on the same file selected
...
...
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment