fix: handle webkitdirectory paths with variable depth
This commit is contained in:
parent
1b018d1f5d
commit
ca6edafbce
@ -4032,13 +4032,13 @@ func (u *UI) actionFaceGalleryImport(w http.ResponseWriter, r *http.Request) {
|
||||
count := 0
|
||||
for _, files := range r.MultipartForm.File {
|
||||
for _, hdr := range files {
|
||||
// webkitdirectory sends files with relative paths like "person_name/photo.jpg"
|
||||
parts := strings.SplitN(filepath.ToSlash(hdr.Filename), "/", 2)
|
||||
// webkitdirectory paths can have varying depth, extract last dir as person name
|
||||
parts := strings.Split(strings.ReplaceAll(hdr.Filename, "\\", "/"), "/")
|
||||
if len(parts) < 2 {
|
||||
continue
|
||||
}
|
||||
personName := strings.TrimSpace(parts[0])
|
||||
fileName := filepath.Base(parts[1])
|
||||
personName := strings.TrimSpace(parts[len(parts)-2])
|
||||
fileName := filepath.Base(parts[len(parts)-1])
|
||||
if personName == "" || fileName == "" {
|
||||
continue
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user