1
0
mirror of https://shylinux.com/x/ContextOS synced 2025-04-25 16:58:06 +08:00

add up.html

This commit is contained in:
shaoying 2018-05-21 16:51:59 +08:00
parent df2cb8faf0
commit 1ccf015b8b
3 changed files with 27 additions and 14 deletions

View File

@ -1,10 +1,3 @@
~aaa
login root root
~ssh
config domain tce
dial "shylinux.com:9090"
~nfs
command add git status
command add git branch
source etc/local.shy
~aaa login root root

View File

@ -116,11 +116,12 @@ func (web *WEB) generate(m *ctx.Message, uri string, arg ...string) string { //
func (web *WEB) AppendJson(msg *ctx.Message) string { // {{{
meta := map[string][]string{}
for _, v := range msg.Meta["append"] {
meta[v] = msg.Meta[v]
if meta["result"] = msg.Meta["result"]; msg.Has("append") {
meta["append"] = msg.Meta["append"]
for _, v := range msg.Meta["append"] {
meta[v] = msg.Meta[v]
}
}
meta["result"] = msg.Meta["result"]
meta["append"] = msg.Meta["append"]
b, e := json.Marshal(meta)
msg.Assert(e)
@ -153,6 +154,9 @@ func (web *WEB) Trans(m *ctx.Message, key string, hand func(*ctx.Message, *ctx.C
for k, v := range r.Form {
msg.Add("option", k, v...)
}
for k, v := range r.PostForm {
msg.Add("option", k, v...)
}
for _, v := range r.Cookies() {
msg.Add("option", v.Name, v.Value)
}
@ -555,7 +559,18 @@ var Index = &ctx.Context{Name: "web", Help: "应用中心",
file, header, e := r.FormFile("file")
m.Assert(e)
f, e := os.Create(path.Join(m.Conf("upload_dir"), header.Filename))
dir := r.FormValue("path")
if dir == "" {
dir = m.Conf("upload_dir")
}
name := path.Join(dir, header.Filename)
m.Append("path", name)
if _, e := os.Stat(name); e == nil {
m.Echo("failure, file already exist!")
return
}
f, e := os.Create(name)
m.Assert(e)
n, e := io.Copy(f, file)

5
usr/up.html Normal file
View File

@ -0,0 +1,5 @@
<form method="POST" action="/upload" enctype="multipart/form-data">
<input type="text" name="path" value="tmp">
<input type="file" name="file">
<input type="submit">
</form>