以文本方式查看主题 - Foxtable(狐表) (http://foxtable.com/bbs/index.asp) -- 专家坐堂 (http://foxtable.com/bbs/list.asp?boardid=2) ---- 修改信息图片保存问题 (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=139176) |
-- 作者:lxhmax -- 发布时间:2019/8/7 12:30:00 -- 修改信息图片保存问题 老师,我想问下这个修改图片的怎么保存,这段代码是修改信息的代码,图片我已经上传过了,然后进入这个修改界面,点确定的时候图片字段的内容就回被清除,只有重新添加的图片才能保存 Dim e As RequestEventArgs = args(0) Dim wb As New WeUI Dim bh As String = e.GetValues("id") Dim ls As new List(Of String) If e.PostValues.Count = 0 Then Dim r As DataRow = DataTables("房产信息").Find("房产编号 = \'" & bh & "\'") wb.AddForm("","form1","fyxg.htm?id=" & bh) With wb.AddInputGroup("form1","ipg7","增加图片") Dim lst As List(of String) = r.Lines("图片") With .AddUploader("图片","图片",True) \'True表示允许上传多个文件 .AllowDelete = True \'允许删除 .Incremental = True \'允许 重复选择文件或连续拍照 For Each s As String In lst .AddImage("./images/fcs/" & s,"./images/fcs/" & s) Next End With End With With wb.AddButtonGroup("form1","btg1",True) .Add("btn1", "确定", "button").Attribute= "" \'调用js函数上传 End With wb.AddToast("","tst1", "正在上传",1) wb.AddToast("","tst2", "上传成功",0) With wb.AddDialog("","dlg1", "提示","信息修改成功!") \'增加订单成功提示框 .AddButton("btnYes","确定","fyxx.htm?id=" & bh ).Kind = 1 End With wb.AddToast("","tst3", "上传失败",0).Icon= "warn" wb.AppendHTML("<script src=\'./lib/ajaxform.js\'></script>") \'引入脚本文件 e.WriteString(wb.Build) \'生成网页 Else Dim nms() As String = {"区域"} \'不能为空的列名数组 Dim dr As DataRow = DataTables("房产信息").Find("房产编号 = \'" & bh & "\'") For Each nm As String In nms If e.PostValues.ContainsKey(nm) Then dr(nm) = e.PostValues(nm) End If Next Dim i As Integer = 0 Dim a As String For Each key As String In e.Files.Keys For Each fln As String In e.Files(key) i = i + 1 a = dr("房产编号") & "-" & i & ".jpg" e.SaveFile(key, fln , ProjectPath & "Attachments\\web\\images\\fcs\\" & a) ls.add(a) Next Next dr.Lines("图片") = ls \'保存并生成增加成功提示页面 dr.save() With wb.AddMsgPage("","msgpage","增加成功", "好好学习,天天向上") \'生成成功提示页 .AddButton("btn1","继续增加","fyxz.htm") End With e.WriteString(wb.Build) End If |
-- 作者:有点蓝 -- 发布时间:2019/8/7 14:03:00 -- …… Dim i As Integer = 0 Dim a As String ls = dr.Lines("图片") For Each key As String In e.Files.Keys For Each fln As String In e.Files(key) i = i + 1 a = dr("房产编号") & "-" & i & ".jpg" e.SaveFile(key, fln , ProjectPath & "Attachments\\web\\images\\fcs\\" & a) ls.add(a) Next Next dr.Lines("图片") = ls \'保存并生成增加成功提示页面 dr.save() ……
|
-- 作者:lxhmax -- 发布时间:2019/8/7 14:15:00 -- 老师,这样可以保留原来的图片字段内容,但是我修改或者删除还是无效的,如果是新增,新增图片的命名会跟之前的图片命名重复 |
-- 作者:有点蓝 -- 发布时间:2019/8/7 14:26:00 -- 那就使用时间命名,不要使用序号命名 a = dr("房产编号") & "-" & format(date.now,"yyyyMMddHHmmssffff") & ".jpg" 没看到1楼有删除文件的代码,参考:http://www.foxtable.com/mobilehelp/topics/0094.htm
|
-- 作者:lxhmax -- 发布时间:2019/8/7 16:11:00 -- 老师,这个调用的是一个路径,我怎么删除字段里对应的图片名字? 或者说,我重新获取所有图片的名字填入字段可以吗?
|
-- 作者:有点蓝 -- 发布时间:2019/8/7 16:18:00 -- 方法1,替换掉: Dim Files = e.PostValues("up1_deleted").Split("|") For Each File As String In Files output,show(file) File.replace("./images/fcs/","") 2、试试这种方式获取名称 msgbox(FileSys.GetName(file)) |
-- 作者:lxhmax -- 发布时间:2019/8/9 11:30:00 -- 是因为我引用脚本的问题吗? If e.PostValues.ContainsKey("up1_deleted") Then MessageBox.Show(1) End If 我删除图片不会触发这段代码的~
|
-- 作者:有点蓝 -- 发布时间:2019/8/9 11:51:00 -- 在网页后台httprequest事件里调用的,不是在表事件里调用的:http://www.foxtable.com/mobilehelp/topics/0094.htm |
-- 作者:lxhmax -- 发布时间:2019/8/9 12:00:00 -- 老师,是在自定义函数里面,删除图片没响应 Dim e As RequestEventArgs = args(0) Dim wb As New WeUI Dim bh As String = e.GetValues("id") Dim ls As new List(Of String) If e.PostValues.Count = 0 Then Dim r As DataRow = DataTables("房产信息").Find("房产编号 = \'" & bh & "\'") wb.AddForm("","form1","fyxg.htm?id=" & bh) With wb.AddInputGroup("form1","ipg6","房源详情") .AddTextArea("房源详情描述",5).Value = r("房源详情描述") End With With wb.AddInputGroup("form1","ipg7","增加图片") Dim lst As List(of String) = r.Lines("图片") With .AddUploader("图片","图片",True) \'True表示允许上传多个文件 .AllowDelete = True \'允许删除 .Incremental = True \'允许 重复选择文件或连续拍照 For Each s As String In lst .AddImage("./images/fcs/" & s,"./images/fcs/" & s) Next End With End With With wb.AddButtonGroup("form1","btg1",True) .Add("btn1", "确定", "button").Attribute= "" \'调用js函数上传 End With wb.AddToast("","tst1", "正在上传",1) wb.AddToast("","tst2", "上传成功",0) With wb.AddDialog("","dlg1", "提示","信息修改成功!") \'增加订单成功提示框 .AddButton("btnYes","确定","fyxx.htm?id=" & bh ).Kind = 1 End With wb.AddToast("","tst3", "上传失败",0).Icon= "warn" wb.AppendHTML("<script src=\'./lib/ajaxform.js\'></script>") \'引入脚本文件 e.WriteString(wb.Build) \'生成网页 Else Dim nms() As String = {"区域"} \'不能为空的列名数组 nms = New String() {"区域","特色服务"} \'重新定义了nms数组,增加了两列. Dim dr As DataRow = DataTables("房产信息").Find("房产编号 = \'" & bh & "\'") For Each nm As String In nms If e.PostValues.ContainsKey(nm) Then dr(nm) = e.PostValues(nm) End If Next Dim i As Integer = 0 Dim a As String ls = dr.Lines("图片") \'新增 For Each key As String In e.Files.Keys For Each fln As String In e.Files(key) i = i + 1 a = dr("房产编号") & "-" & format(Date.now,"yyyyMMddHHmmssffff") & ".jpg" e.SaveFile(key, fln , ProjectPath & "Attachments\\web\\images\\fcs\\" & a) ls.add(a) Next Next dr.Lines("图片") = ls \'删除 If e.PostValues.ContainsKey("up1_deleted") Then MessageBox.Show(1) \'Dim Files = e.PostValues("up1_deleted").Split("|") \'For Each File As String In Files \'File.replace("./images/fcs/","") \'msgbox(FileSys.GetName(file)) \'Next End If \'保存并生成增加成功提示页面 dr.save() With wb.AddMsgPage("","msgpage","增加成功", "好好学习,天天向上") \'生成成功提示页 .AddButton("btn1","继续增加","fyxx.htm") End With e.WriteString(wb.Build) End If
|
-- 作者:有点蓝 -- 发布时间:2019/8/9 12:06:00 -- 把8楼帮助仔细认真看看,每一个字都咀嚼一下 |