Reputation: 726
I'm trying to handle multiple files upload in golang-revel
. Here is the documentation that i follow.
This is what i've tried
HTML
<input id="file" type="file" name="file" multiple class="form-control" placeholder="Select Files">
GO
var (
files [][]byte
)
c.Params.Bind(&files, "file")
// c.Validation.MinSize(files, 1).Message("You cannot submit less than 1 files")
c.Validation.MaxSize(files, 3).Message("You cannot submit more than 3 files")
filenames := ""
file_ext := ""
for i, _ := range files {
filenames += tools.ReplaceName(c.Params.Files["files[]"][i].Filename, fmt.Sprint(c.Params.Files["file"][0].Size), true) + "|"
file_ext += strings.Replace(filenames[strings.LastIndex(filenames, "."):], ".", "", -1) + "|"
print("INSIDE FOR LOOP")
print(filenames)
print(file_ext)
}
print("FILE NAMES AND EXT")
print(filenames)
print(file_ext)
The Problem is the file is c.Params.Bind(&files, "file")
produced empty []
array. But it worked when i tried to upload single file.
Why when i upload multiple files it can't receive any ?
Upvotes: 1
Views: 96