View definition

(*Controller).GetFiles

Defined in github.com/astaxie/beego/controller.go

Description

GetFiles return multi-upload files files, err:=c.Getfiles("myfiles")

if err != nil {
	http.Error(w, err.Error(), http.StatusNoContent)
	return
}

for i, _ := range files {

//for each fileheader, get a handle to the actual file
file, err := files[i].Open()
defer file.Close()
if err != nil {
	http.Error(w, err.Error(), http.StatusInternalServerError)
	return
}
//create destination file making sure the path is writeable.
dst, err := os.Create("upload/" + files[i].Filename)
defer dst.Close()
if err != nil {
	http.Error(w, err.Error(), http.StatusInternalServerError)
	return
}
//copy the uploaded file to the destination file
if _, err := io.Copy(dst, file); err != nil {
	http.Error(w, err.Error(), http.StatusInternalServerError)
	return
}

}

GetFiles is referenced in 1 repository

github.com/gwduan/beego-demo