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
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
6 deletions
app/index.html
app/js/app.js
app/index.html
View file @
ecfbca9
...
@@ -108,7 +108,7 @@
...
@@ -108,7 +108,7 @@
<div
class=
"col-lg-12"
>
<div
class=
"col-lg-12"
>
<center>
<center>
<form
id=
"fileUploadForm"
>
<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>
<button
class=
"btn btn-primary"
v-on:click
.
stop
.
prevent=
"upload()"
id=
"uploadButton"
>
Upload
</button>
</form>
</form>
</center>
</center>
...
...
app/js/app.js
View file @
ecfbca9
...
@@ -129,21 +129,32 @@ function upload() {
...
@@ -129,21 +129,32 @@ function upload() {
// detach event handler
// detach event handler
$
(
app
.
$els
.
upload
).
off
(
'change'
);
$
(
app
.
$els
.
upload
).
off
(
'change'
);
var
file
=
app
.
$els
.
upload
.
files
[
0
];
var
length
=
app
.
$els
.
upload
.
files
.
length
;
var
done
=
0
;
function
uploadFile
(
file
)
{
var
path
=
encode
(
sanitize
(
app
.
path
+
'/'
+
file
.
name
));
var
path
=
encode
(
sanitize
(
app
.
path
+
'/'
+
file
.
name
));
var
formData
=
new
FormData
();
var
formData
=
new
FormData
();
formData
.
append
(
'file'
,
file
);
formData
.
append
(
'file'
,
file
);
superagent
.
put
(
'/api/files'
+
path
).
query
({
username
:
app
.
session
.
username
,
password
:
app
.
session
.
password
}).
send
(
formData
).
end
(
function
(
error
,
result
)
{
superagent
.
put
(
'/api/files'
+
path
).
query
({
username
:
app
.
session
.
username
,
password
:
app
.
session
.
password
}).
send
(
formData
).
end
(
function
(
error
,
result
)
{
app
.
busy
=
false
;
if
(
result
&&
result
.
statusCode
===
401
)
return
logout
();
if
(
result
&&
result
.
statusCode
===
401
)
return
logout
();
if
(
result
&&
result
.
statusCode
!==
201
)
return
console
.
error
(
'Error uploading file: '
,
result
.
statusCode
);
if
(
result
&&
result
.
statusCode
!==
201
)
console
.
error
(
'Error uploading file: '
,
result
.
statusCode
);
if
(
error
)
return
console
.
error
(
error
);
if
(
error
)
console
.
error
(
error
);
++
done
;
if
(
done
>=
length
)
{
app
.
busy
=
false
;
refresh
();
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
// 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