### 文件上传
通过ctx.Request().FormFile(key string) (*UploadFile, error) 获取上传文件
返回*dotweb.UploadFile 文件
~~~
type UploadFile struct {
File multipart.File
Header *multipart.FileHeader
fileExt string //file extensions
fileName string
fileSize int64
}
~~~
用法:
~~~
func FileUpload(ctx dotweb.Context) error {
upload, err := ctx.Request().FormFile("file")
if err != nil {
return err
} else {
_, err = upload.SaveFile("d:\\" + upload.FileName())
if err != nil {
return err
} else {
ctx.WriteString("SaveFile success || ", upload.FileName(), " || ", upload.GetFileExt(), " || ", upload.Size())
return nil
}
}
}
~~~
这里将从表单file获取上传的文件,通过UploadFile相关属性,做文件存储、信息转换等工作