以文本方式查看主题 - Foxtable(狐表) (http://foxtable.com/bbs/index.asp) -- 专家坐堂 (http://foxtable.com/bbs/list.asp?boardid=2) ---- 如何在合成保存的文件名的时候,加上保存行的ID值 ? (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=141435) |
-- 作者:ycwk -- 发布时间:2019/9/29 9:04:00 -- 如何在合成保存的文件名的时候,加上保存行的ID值 ? Dim nms() As String = {"巡检人","异常情况","处理情况","巡检时间"} Dim dr As DataRow = DataTables("机房交班巡检表").AddNew() For Each nm As String In nms dr(nm) = e.PostValues(nm) \' msgbox(dr(nm)) Next For Each key As String In e.Files.Keys If key = "up1" Then For Each fln As String In e.Files(key) e.SaveFile(key,fln,"c:\\test\\" & "B3_" & Format(Date.now, "yyMMddhhmmss") & ".jpg") \'请问要要以 B3_ID_时间的方式保存 照片名,如何写代码? Next dr.Lines("1机房照片") = e.Files(key) End If If key = "up2" Then For Each fln As String In e.Files(key) e.SaveFile(key, fln, ProjectPath & "Attachments\\" & fln) Next dr.Lines("2机房照片") = e.Files(key) End If If key = "up3" Then For Each fln As String In e.Files(key) e.SaveFile(key, fln, ProjectPath & "Attachments\\" & fln) Next dr.Lines("3机房照片") = e.Files(key) End If If key = "up4" Then For Each fln As String In e.Files(key) e.SaveFile(key, fln, ProjectPath & "Attachments\\" & fln) Next dr.Lines("4机房照片") = e.Files(key) End If Next dr.Save() e.WriteString("OK") End If
[此贴子已经被作者于2019/9/29 9:04:27编辑过]
|
-- 作者:有点蓝 -- 发布时间:2019/9/29 9:21:00 -- e.SaveFile(key,fln,"c:\\test\\" & "B3_" & dr("ID") & "_" & Format(Date.now, "yyMMddhhmmss") & ".jpg") |
-- 作者:ycwk -- 发布时间:2019/9/29 9:37:00 -- 问题是 数据保存在20行,但msgbox结果是21,这是怎么回事? Dim nms() As String = {"巡检人","异常情况","处理情况","巡检时间"} Dim dr As DataRow = DataTables("机房交班巡检表").AddNew() For Each nm As String In nms dr(nm) = e.PostValues(nm) \' msgbox(dr(nm)) Next \'msgbox(dr("_identify")) For Each key As String In e.Files.Keys If key = "up1" Then Dim str_allphotoname As New List(of String) For Each fln As String In e.Files(key) \'e.SaveFile(key, fln, ProjectPath & "Attachments\\" & fln) \'fln是用户上传的文件名称,不含路径. 第三个参数是要保存到本地的文件名称,含路径 Dim str_photoname As String="B3_" & dr("_identify") & "_" & Format(Date.now, "yyMMddhhmmss") & ".jpg" e.SaveFile(key,fln,"c:\\test\\" & str_photoname) \'文件名保存要以 保存路径&文件名的方式保存 str_allphotoname.add(str_photoname) \'dr("中心机房照片")=str_photoname \'只有一张照片的时候,可以这样,有多张照片的时候,应该还是用lines Next \' dr.Lines("中心机房照片") = e.Files(key) \'lines 以字符集合的形式返回或设置单元格内容. 可能是用来对付用户在uploader中上传多张照片的情况(如果只有一张的话,王昆觉得应该不用lines) dr.Lines("中心机房照片")=str_allphotoname \'只有一张照片的时候,可以这样,有多张照片的时候,应该还是用lines End If If key = "up2" Then For Each fln As String In e.Files(key) e.SaveFile(key, fln, ProjectPath & "Attachments\\" & fln) Next dr.Lines("一号楼机房照片") = e.Files(key) End If If key = "up3" Then For Each fln As String In e.Files(key) e.SaveFile(key, fln, ProjectPath & "Attachments\\" & fln) Next dr.Lines("医技楼机房照片") = e.Files(key) End If If key = "up4" Then For Each fln As String In e.Files(key) e.SaveFile(key, fln, ProjectPath & "Attachments\\" & fln) Next dr.Lines("南湖机房照片") = e.Files(key) End If Next dr.Save() [此贴子已经被作者于2019/9/29 9:39:39编辑过]
|
-- 作者:有点蓝 -- 发布时间:2019/9/29 9:39:00 -- Dim dr As DataRow = DataTables("机房交班巡检表").AddNew() For Each nm As String In nms dr(nm) = e.PostValues(nm) \' msgbox(dr(nm)) Next dr.save 保存后的_identify才是准确的 msgbox(dr("_identify"))
|
-- 作者:ycwk -- 发布时间:2019/9/29 9:46:00 -- 我在前面先加了个dr.save,但是仍然在20行保存的是21 ,咋回事? Dim nms() As String = {"巡检人","异常情况","处理情况","巡检时间"} Dim dr As DataRow = DataTables("机房交班巡检表").AddNew() dr.Save \'保存后的_identify才是准确的 For Each nm As String In nms dr(nm) = e.PostValues(nm) Next \'msgbox(dr("_identify")) For Each key As String In e.Files.Keys If key = "up1" Then Dim str_allphotoname As New List(of String) For Each fln As String In e.Files(key) \'e.SaveFile(key, fln, ProjectPath & "Attachments\\" & fln) \'fln是用户上传的文件名称,不含路径. 第三个参数是要保存到本地的文件名称,含路径 Dim str_photoname As String="B3_" & dr("_identify") & "_" & Format(Date.now, "yyMMddhhmmss") & ".jpg" e.SaveFile(key,fln,"c:\\test\\" & str_photoname) \'文件名保存要以 保存路径&文件名的方式保存 str_allphotoname.add(str_photoname) \'dr("中心机房照片")=str_photoname \'只有一张照片的时候,可以这样,有多张照片的时候,应该还是用lines Next \' dr.Lines("中心机房照片") = e.Files(key) \'lines 以字符集合的形式返回或设置单元格内容. 可能是用来对付用户在uploader中上传多张照片的情况(如果只有一张的话,王昆觉得应该不用lines) dr.Lines("中心机房照片")=str_allphotoname \'只有一张照片的时候,可以这样,有多张照片的时候,应该还是用lines End If If key = "up2" Then For Each fln As String In e.Files(key) e.SaveFile(key, fln, ProjectPath & "Attachments\\" & fln) Next dr.Lines("一号楼机房照片") = e.Files(key) End If If key = "up3" Then For Each fln As String In e.Files(key) e.SaveFile(key, fln, ProjectPath & "Attachments\\" & fln) Next dr.Lines("医技楼机房照片") = e.Files(key) End If If key = "up4" Then For Each fln As String In e.Files(key) e.SaveFile(key, fln, ProjectPath & "Attachments\\" & fln) Next dr.Lines("南湖机房照片") = e.Files(key) End If Next dr.Save() e.WriteString("OK") [此贴子已经被作者于2019/9/29 9:46:48编辑过]
|
-- 作者:有点蓝 -- 发布时间:2019/9/29 10:06:00 -- 行号和_identify不是一回事啊,并不是一一对应的 |
-- 作者:ycwk -- 发布时间:2019/9/29 10:13:00 -- 幸亏老师提醒一下,把_identify放出来了,不然在里面看晕了,今天不太适合写代码 |