老师,我采用后台上传图片到二进制列时发现,上传之前图片的校验码与上传完了之后再下载的本地的图片的校验码不一致,这是怎么回事呢?上传图片至二进制列的代码
Dim fx As String = pth & bh & ".png"
Dim imgStream As New IO.MemoryStream '声明 图片流 为新的 io临时储存空间
Dim b As New Bitmap(fx)
Dim wj As String = FileSys.GetName(fx)
Dim sx As String = CRCCheckFile(fx)
b.Save(imgStream, System.Drawing.Imaging.ImageFormat.png) '原为照片格式是jpeg
Dim imageByte As Byte() = imgStream.GetBuffer '
imgStream.Dispose() '处理
Dim ImageString As String = BitConverter.ToString(imageByte).Replace("-", "") '
Dim cmd As SQL Command = new SQL Command()
cmd.Conne cti
cmd.Comm andText = "up date {表} set 照片 = 0x" + ImageString + ",校验值 = '" & sx & "',文件名 = '" & wj & "' where 编号 = '" & bh & "' and ID = '" & xtid & "'"
cmd.ExecuteNonQuery()
图片能成功上传,但下载后与本地的校验码不匹配
下面使用命令检查时发现:
Dim drs As DataRow= Tables("全表").Current.DataRow
Dim ss As String = drs("编号") & ".png"
Dim pth As String = ProjectPath & "Attachments\图片\"
Dim fl As String = pth & ss
drs.SQLLoadFile("照片",fl)
Dim sx1 As String = CRCCheckFile(fl) '从二进制列下载下来图片的校验值
Dim sxx1 As String = CRCCheckFile("C:\建筑装饰管理系统mobile\Attachments\" & ss) '用于上传二进制图片的校验值
output.show("二进制列保存的校验值:" & drs.SQLGetValue("校验值") & "-下载到本地图片校验值:" & sx1 & "-用于上传的图片校验值:" & sxx1)
结果显示:二进制列保存的校验值:0xceec0a4e-下载到本地图片校验值:0x337bcaf7-用于上传的图片校验值:0xceec0a4e
导致每次校验不成功后重新下载,但下载后又再次验证不通过继续重新下载.我应该怎么处理呢
[此贴子已经被作者于2019/2/25 13:25:03编辑过]