Dim ftp1 As New FtpClient
ftp1.Host=
ftp1.Account =
ftp1.Password =
Dim r As Row = Tables("相片处理_table1").Current
Dim t1 As String = e.Form.Controls("textbox1").text
Dim wjm As String=""
If t1>""
If ValidPIN(r("身份证件号"))= True
wjm = r("身份证件号")
ElseIf r("学籍号")>""
wjm=r("学籍号")
Else
messagebox.show("该学生的身份证号和学籍号中至少有一个要正确完整")
Return
End If
If wjm>""
Dim ifo As new FileInfo(t1)
If Ifo.Length>40960 '大于40k才压缩
Dim img As image = getimage(t1)
Dim bmp As new bitmap(img.width, img.height)
Dim g = graphics.fromimage(bmp)
g.DrawImage(img, 0, 0, img.Width, img.Height)
Dim jpgEncoder As ImageCodecInfo
Dim codecs() As ImageCodecInfo = ImageCodecInfo.GetImageDecoders
For Each codec As ImageCodecInfo In codecs
If (codec.FormatID = ImageFormat.Jpeg.Guid) Then
jpgEncoder = codec
Exit For
End If
Next
Dim myEncoder As System.Drawing.Imaging.Encoder = System.Drawing.Imaging.Encoder.Quality
Dim myEncoderParameters As EncoderParameters = New EncoderParameters(1)
Dim myEncoderParameter As EncoderParameter = New EncoderParameter(myEncoder, 100) ' 质量级别 0 对应于最大压缩,而质量级别 100 对应于最小压缩
myEncoderParameters.Param(0) = myEncoderParameter
Dim slt As String = ifo.path & wjm & ifo.Extension
bmp.Save(slt,jpgEncoder, myEncoderParameters)
bmp.dispose
g.dispose
Dim img1 As image = getImage(slt)
Dim bmp1 As bitmap
If img1.width > 200 Then
If 200 * (img1.height / img1.width) > 150 Then
bmp1 = new bitmap(img1, 200*(150/(200*(img1.height/img1.width))), 150)
Else
bmp1 = new bitmap(img1, 150, 150 * (img1.height / img1.width))
End If
bmp1.save(slt, ImageFormat.Jpeg)
bmp1.Dispose
End If
If ftp1.Upload(slt,"\xp\" & FileSys.GetName(wjm & Ifo.extension),True) = True Then
r("相片")="\xp\" & FileSys.GetName(wjm & Ifo.extension)
r.save
Else
Messagebox.show("上传失败,请重新上传该文件!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)
End If
Else
If ftp1.Upload(t1,"\xp\" & FileSys.GetName(wjm & Ifo.extension),True) = True Then
r("相片")="\xp\" & FileSys.GetName(wjm & Ifo.extension)
r.save
Else
Messagebox.show("上传失败,请重新上传该文件!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)
End If
End If
End If
Else
messagebox.show("你没打开相片")
End If
我测试了一下选择个png文件传上去后文件还是png呢哪里没有对?