Go-多个文件的formFile [英] Go - formFile for multiple files
本文介绍了Go-多个文件的formFile的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
formFile函数工作正常,但是在文档中 "FormFile返回所提供的表单密钥的第一个文件".有没有一种方法可以获取带有输入的html形式的几个文件:
The formFile function works perfectly but in the docs it´s said that the "FormFile returns the first file for the provided form key". Is there a way of obtaining the several files that an html form with an input like:
<input type="file" name="myfiles" multiple="multiple">
可能会回来吗?
推荐答案
FormFile是一种便捷功能.您可以手动解析并在MultipartForm中找到所需的文件.
FormFile is a convenience function. You can manually parse and find the files you are looking for in the MultipartForm.
req.ParseMultipartForm(32 << 20) // 32MB is the default used by FormFile
fhs := req.MultipartForm.File["myfiles"]
for _, fh := range fhs {
f, err := fh.Open()
// f is one of the files
}
这篇关于Go-多个文件的formFile的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文