mirror of https://github.com/gin-gonic/gin.git
PostForm() handles multipart post
This commit is contained in:
parent
195ea88a28
commit
500d745123
|
@ -30,8 +30,6 @@ const (
|
|||
|
||||
const AbortIndex = math.MaxInt8 / 2
|
||||
|
||||
var _ context.Context = &Context{}
|
||||
|
||||
// Param is a single URL parameter, consisting of a key and a value.
|
||||
type Param struct {
|
||||
Key string
|
||||
|
@ -76,6 +74,8 @@ type Context struct {
|
|||
Accepted []string
|
||||
}
|
||||
|
||||
var _ context.Context = &Context{}
|
||||
|
||||
/************************************/
|
||||
/********** CONTEXT CREATION ********/
|
||||
/************************************/
|
||||
|
@ -231,10 +231,13 @@ func (c *Context) query(key string) (string, bool) {
|
|||
|
||||
func (c *Context) postForm(key string) (string, bool) {
|
||||
req := c.Request
|
||||
req.ParseForm()
|
||||
req.ParseMultipartForm(32 << 20) // 32 MB
|
||||
if values, ok := req.PostForm[key]; ok && len(values) > 0 {
|
||||
return values[0], true
|
||||
}
|
||||
if values, ok := req.MultipartForm.Value[key]; ok && len(values) > 0 {
|
||||
return values[0], true
|
||||
}
|
||||
return "", false
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue