File tree Expand file tree Collapse file tree 1 file changed +3
-3
lines changed Expand file tree Collapse file tree 1 file changed +3
-3
lines changed Original file line number Diff line number Diff line change 7
7
multipart/form-data 不对字符编码。在使用包含文件上传控件的表单时,必须使用该值。
8
8
text/plain 空格转换为 "+" 加号,但不对特殊字符编码。
9
9
10
- 所以,表单的html代码应该类似于 :
10
+ 所以,创建新的表单html文件, 命名为upload.gtpl, html代码应该类似于 :
11
11
12
12
<html>
13
13
<head>
14
14
<title>上传文件</title>
15
15
</head>
16
16
<body>
17
- <form enctype="multipart/form-data" action="http://127.0.0.1:9090 /upload" method="post">
17
+ <form enctype="multipart/form-data" action="/upload" method="post">
18
18
<input type="file" name="uploadfile" />
19
19
<input type="hidden" name="token" value="{{.}}"/>
20
20
<input type="submit" value="upload" />
46
46
}
47
47
defer file.Close()
48
48
fmt.Fprintf(w, "%v", handler.Header)
49
- f, err := os.OpenFile("./test/"+handler.Filename, os.O_WRONLY|os.O_CREATE, 0666)
49
+ f, err := os.OpenFile("./test/"+handler.Filename, os.O_WRONLY|os.O_CREATE, 0666) // 此处假设当前目录下已存在test目录
50
50
if err != nil {
51
51
fmt.Println(err)
52
52
return
You can’t perform that action at this time.
0 commit comments