func UpLoad(w http.ResponseWriter, r *http.Request, _ httprouter.Params) { r.ParseMultipartForm(32 << 20) files := r.MultipartForm.File["file"] len := len(files) for i := 0; i < len; i++ { file, err := files[i].Open() defer file.Close() if err != nil { log.Fatal(err) } fileInfo := files[i] fileDir := "upload" suffixName := path.Ext(fileInfo.Filename) newFileName := strings.Replace(uuid.New().String(), "-", "", -1) + suffixName fileUri := fileDir + newFileName os.Mkdir("./"+fileDir, os.ModePerm) cur, err := os.Create("./" + fileUri) defer cur.Close() if err != nil { log.Fatal(err) } io.Copy(cur, file) } }