html代碼:
<form id="fform" method="POST" enctype="multipart/form-data">
<input id="myfile" name="myfile" type="file" />
<input type="submit" value="保存" />
</form>
beego代碼:
func (this *ServiceController) Upload() {
f, h, _ := this.GetFile("myfile") //獲取上傳的文件
path := SDPATH + h.Filename //文件目錄
f.Close() //關閉上傳的文件,不然的話會出現臨時文件不能清除的情況
this.SaveToFile("myfile", path) //存文件
}
