以下是引用大红袍在2016/8/18 14:59:00的发言:
上传的时候重命名
ftp.Upload(dlg.FileName,"/rszp/文件名字.txt",True)
zp.AddFile("/rszp/文件名字.txt")
大神帮我看看下面这段代码 无论怎么调试都是上传失败,用ftp测试,服务器没问题
服务器的ftp文件夹是OA oa里面有2个文件夹 其中1个是rszp文件夹
Dim dlg As new OpenFileDialog
dlg.Filter = "图片|*.jpg;*.jpeg;*.ico;*.png;*.gif"
If dlg.ShowDialog = DialogResult.OK Then
Dim xg As Integer = dlg.FileName.LastIndexOf("\")'斜杠最后出现的位置
Dim fname As String = dlg.FileName.SubString(xg + 1) '获取所选文件名称 ABC.jpg
Dim ifo As new FileInfo(dlg.filename)
If ifo.Length > 2048000 Then
msgbox("只能上次2M以下的图片!")
Return
End If
Dim ftp As new FTPClient
ftp.host="120.25.196.16"
ftp.Port = 4237
ftp.account="*****"
ftp.password="******"
'ftp.ChangeDir("\rszp")
If ftp.DirExists("\rszp\" & Tables("员工资料").Current("姓名")) = False Then
ftp.MakeDir("\rszp\" & Tables("员工资料").Current("姓名"))
End If
Dim fp As String = "\rszp\" & Tables("员工资料").Current("姓名")
Dim sts As List(of String) = ftp.GetFileList(fp)'获取当前目录的文件列表
For Each st As String In sts
If st = fname Then
MessageBox.Show("服务器上存在同名文件!","提醒")
Return '这里是简化了操作,读者可以自己做是否覆盖的功能
End If
Next
e.Form.text = "文件上传中....请稍候........."
If ftp.Upload(dlg.FileName,fp & "\" & fname) = True Then '若成功上传
e.Form.text = "基本资料"
MessageBox.Show("上传成功!","提醒")
Else
MessageBox.Show("上传失败!","提醒")
e.Form.text = "基本资料"
End If
End If