Dim ftp1 As New FtpClient
ftp1.Host="***"
ftp1.Account = "***"
ftp1.Password = "****
此主题相关图片如下:1.png

" ftp1.Port="22"
ftp1.UTF8 = True
ftp1.Connect
ftp1.RootDir = "\photo\staff"
If ftp1.Connected=True Then
Dim dlg As New OpenFileDialog
dlg.Filter= "图形文件|*.bmp;*.jpg;*.gif"
If dlg.ShowDialog = DialogResult.OK Then
MessageBox.Show("你选择的是:" & dlg.FileName,"提示") '提示用户选择的文件
'Dim piv As WinForm.PictureViewer = e.Form.Controls("员工照片")
Dim gh As WinForm.TextBox = e.Form.Controls("工号")
If gh.value ="" Then
msgbox("请确认员工编号!")
Return
End If
Dim nm As String = gh.value & ".jpg"
Dim pth As String = dlg.FileName
Dim files = ftp1.GetFileList("\photo\staff")
If files.contains(nm) Then '判断是否有重名的图片
Dim Result As DialogResult
Result = MessageBox.Show("该名员工已经上传过相片,是否重新上传替换?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question)
If Result = DialogResult.Yes Then
ftp1.DeleteFile(nm)
ftp1.Upload(pth,nm)
msgbox("员工照片上传成功!")
End If
Else
If ftp1.Upload(pth,nm) = True Then
Dim r As DataRow =DataTables("职员表").SQLFind("工号='" & gh.value & "'")
If r IsNot Nothing Then
r("员工照片")= "\photo\staff\" & nm
r.Save
Else
_piclujing="\photo\staff\" & nm
End If
Messagebox.show("上传完成!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)
Else
Messagebox.show("上传失败!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)
End If
End If
End If
Else
MessageBox.show("服务器连接失败!")
End If