From ca6edafbce0ad2ad3731b15ddeccbf85b5d3cf68 Mon Sep 17 00:00:00 2001 From: tian <11429339@qq.com> Date: Fri, 8 May 2026 10:15:12 +0800 Subject: [PATCH] fix: handle webkitdirectory paths with variable depth --- internal/web/ui.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/internal/web/ui.go b/internal/web/ui.go index 8be7ba9..d116457 100644 --- a/internal/web/ui.go +++ b/internal/web/ui.go @@ -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 }