[英]File Upload Failed using SIRIS
我想使用SIRIS和Postman将文件上传到服务器。
去程序
package main
import (
"github.com/go-siris/siris"
)
func main() {
app := siris.New()
app.Post("/", handleFileUpload)
app.Run(siris.Addr(":8080"))
}
func handleFileUpload(ctx siris.Context) {
ctx.Writef("Hello<br/>")
file, info, err := ctx.FormFile("filee")
if err != nil {
ctx.StatusCode(iris.StatusInternalServerError)
ctx.HTML("Error while uploading: <b>" + err.Error() + "</b>")
return
}
defer file.Close()
fn := info.Filename
ctx.Writef("File Name: " + fn)
}
邮差
但是Postman只能得到错误消息:
你好
上传时出错: 请求Content-Type不是multipart / form-data
为什么会这样?
要正确处理文件,上传html表单应具有属性
enctype="multipart/form-data"
https://www.w3schools.com/php/php_file_upload.asp
PS我不建议使用虹膜。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.