Dim ftp1 As New FtpClient
ftp1.Host=""
ftp1.Account = ""
ftp1.Password = ""
Dim tb As Table =Tables("贴图_table1")
If tb.Rows.Count>0
Dim r As Row = tb.Current
Dim t1 As String = e.Form.Controls("textbox1").text
Dim t2 As String = e.Form.Controls("textbox2").text
Dim t3 As String = e.Form.Controls("textbox3").text
Dim wjm As String=""
If ValidPIN(r("身份证件号"))= True
wjm = r("身份证件号")
ElseIf r("学籍号")>""
wjm =r("学籍号")
Else
messagebox.show("该学生的身份证号和学籍号中至少有一个要正确完整")
Return
End If
If t1>""
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 > 400 Then
If 400 * (img1.height / img1.width) > 300 Then
bmp1 = new bitmap(img1, 400*(300/(400*(img1.height/img1.width))), 300)
Else
bmp1 = new bitmap(img1, 300, 300 * (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
e.Form.Controls("PictureBox1").image=getimage(slt)
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
老师,这个代码之可以用,但现在出现有的电脑传一张图片就显示停止运行,然后就关闭了,这是什么原因,怎么改进这个