Skip to content

Commit 1d69494

Browse files
committed
Update zh 04.5.md
1 parent 04b51ac commit 1d69494

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

zh/04.5.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,14 @@
77
multipart/form-data 不对字符编码。在使用包含文件上传控件的表单时,必须使用该值。
88
text/plain 空格转换为 "+" 加号,但不对特殊字符编码。
99

10-
所以,表单的html代码应该类似于:
10+
所以,创建新的表单html文件, 命名为upload.gtpl, html代码应该类似于:
1111

1212
<html>
1313
<head>
1414
<title>上传文件</title>
1515
</head>
1616
<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">
1818
<input type="file" name="uploadfile" />
1919
<input type="hidden" name="token" value="{{.}}"/>
2020
<input type="submit" value="upload" />
@@ -46,7 +46,7 @@
4646
}
4747
defer file.Close()
4848
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目录
5050
if err != nil {
5151
fmt.Println(err)
5252
return

0 commit comments

Comments
 (0)