I am almost done with an issue that has stomped me as I am new to Golang, I am basically trying to get the absolute path of a file inside the os.open method. I have been trying all types of things but nothing works
func UploadProfile(w http.ResponseWriter, r *http.Request) {
r.ParseForm()
infile, header, err := r.FormFile("upload_file")
if err != nil {
http.Error(w, "Error parsing uploaded file: "+err.Error(), http.StatusBadRequest)
return
}
defer infile.Close()
absolue_path := string(filepath.Abs(header.Filename))
// I want to get the absolute path in os.Open
file, err := os.Open(absolute_path)
}
for instance if I hard code the string in the os.Open like /Users/Documents/pictures/cats.jpg then the file uploads successfully . When i try to get the absolute path and put it inside the os.Open I get this error on runtime multiple-value filepath.Abs() in single-value context . Is there any other way that I can get the path of the file so that I can put it inside that method ?