sanitizeUploadName function
Strips path separators and ./.. segments from a picked file name
(some browsers send a webkitRelativePath), so the upload stays inside
the target directory. Returns the cleaned relative path — possibly with
subdirectories — or an empty string when nothing usable is left.
Implementation
String sanitizeUploadName(String name) {
final segments = name
.split(RegExp(r'[/\\]'))
.where((s) => s.isNotEmpty && s != '.' && s != '..')
.toList();
return segments.join('/');
}