Experience in using the GetFile () function of beego framework

GetFile () is the information that users get to upload pictures

func (c *Controller) GetFile(key string) (multipart.File, *multipart.FileHeader, error) 

A total of three parameters are returned: the first parameter FileName (file name), the second parameter FileHeader (file header information, including file size, etc.) The third parameter is error

When using the GetFile () function, add an attribute to the form form, enctype = "multipart / form-data", otherwise an error will be reported:

例如:<form method="post" action="/addArticle" enctype="multipart/form-data">

Guess you like

Origin www.cnblogs.com/zhaopp/p/12719942.html