If e.Files.ContainsKey("img01")
Dim lst As List(of String) = dr.Lines("img01")
For Each fln As String In e.Files("img01")
Dim NewName As String = fln '为防止上传同名文件而定义一个新文件名称
Dim idx As Integer=fln.LastIndexOf(".")
Dim cnt As Integer = 1
Do Wh ile FileSys.File Exists(".\Photo\" & NewName) '判断文件夹是否存在同名文件
NewName = fln.Insert(idx,primaryKey & "_" & cnt) '如果碰到有同名文件上传,就在文件名称后面自动+记录行号 + 1
cnt = cnt + 1
Loop
e.SaveFile(key,fln,".\Photo\" & NewName) '以新的文件名保存到的文件夹,
lst.Add(NewName)
Next
dr.Lines("img01")=lst '但保存在字段名中的文件名还是原来的文件名,
End If
dr.Save()