以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  [求助]ftp上传文件到服务器  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=81196)

--  作者:zcgmxf
--  发布时间:2016/2/20 16:11:00
--  [求助]ftp上传文件到服务器
老师,拍摄照片后,通过一个保存按钮上传本地服务器,总是上传失败。照片控件绑定到表A的照片列,照片控件设置为远程文件地址如下,照片所在窗口有一保存按钮,chick事件如下。“中心文件管理”是ftp网站的物理路径, 文件收发”是它下面的一个子目录请指点。谢谢!
Dim zp  As  Image  = e.Form.Controls("照片").Image
Dim wjm As WinForm.Label = e.Form.Controls("文件名")
If zp IsNot Nothing Then
    If Forms("图片管理器").Opened Then
        Dim path As String = ProjectPath & "Attachments\\" & wjm.text & ".jpg"
        zp.Save(path)
        
        Dim ftp1 As New FtpClient
        ftp1.Host="192.168.8.200"
        ftp1.Account = "dcqcdc"
        ftp1.Password = "123456789"
        If ftp1.Upload("F:\\数据库\\中心文件\\Attachments\\" & wjm.text & ".jpg","\\update\\文件收发\\"& wjm.text & ".jpg") = True Then
            Messagebox.show("上传完成!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)
        Else
            Messagebox.show("上传失败!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)
        End If
        
        Forms("图片管理器").Controls("PictureViewer1").AddFile(FileSys.GetName(path))
        e.Form.Close
    End If
Else
    MessageBox.Show("请拍摄照片后再保存!","错误",MessageBoxButtons.OK,MessageBoxIcon.Error)
End If


--  作者:zcgmxf
--  发布时间:2016/2/20 16:50:00
--  
哪位大师指点指点吧。谢谢了!
--  作者:Hyphen
--  发布时间:2016/2/20 16:51:00
--  
上传失败提示什么错误?

Ftp是否能正常访问?

--  作者:zcgmxf
--  发布时间:2016/2/20 16:55:00
--  

ftp没问题的,就是上传失败

[此贴子已经被作者于2016/2/20 17:01:19编辑过]

--  作者:Hyphen
--  发布时间:2016/2/20 17:01:00
--  
Ftp通过其它方式是否能正常访问,比如浏览器
--  作者:zcgmxf
--  发布时间:2016/2/20 17:04:00
--  
手动上传下载都没问题
--  作者:zcgmxf
--  发布时间:2016/2/20 17:06:00
--  
用共享文件夹,读取身份证后照片是自动上传的。ftp设置好是不是自动上传的?
--  作者:zcgmxf
--  发布时间:2016/2/20 17:16:00
--  

老师,就是在论坛里“图片管理器加上拍照扫描功能”实例的保存照片按钮中加代码

Dim zp  As  Image  = e.Form.Controls("照片").Image
Dim wjm As WinForm.Label = e.Form.Controls("文件名")
If zp IsNot Nothing Then
    If Forms("图片管理器").Opened Then
        Dim path As String = ProjectPath & "Attachments\\" & wjm.text & ".jpg"
        zp.Save(path)
        Forms("图片管理器").Controls("PictureViewer1").AddFile(FileSys.GetName(path))
        e.Form.Close
    End If
Else
    MessageBox.Show("请拍摄照片后再保存!","错误",MessageBoxButtons.OK,MessageBoxIcon.Error)
End If

 

在保存时上传的ftp服务器

 

 

 

Dim ftp1 As New FtpClient
ftp1
.Host="196.128.143.28"
ftp1
.Account = "foxuser"
ftp1
.Password = "138238110"
If
ftp1.Upload("c:\\data\\Desert.jpg","\\update\\Desert.jpg") = True Then
   
Messagebox.show("上传完成!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)
Else
   
Messagebox.show("上传失败!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)
End If


--  作者:zcgmxf
--  发布时间:2016/2/20 20:44:00
--  

谁来告诉我为什么上传失败啊,在命令窗口测试直接的文件上传也不行啊 是不是下面的代码有问题啊

 

Dim ftp1 As New FtpClient
ftp1
.Host="196.128.143.28"
ftp1
.Account = "foxuser"
ftp1
.Password = "138238110"
If
ftp1.Upload("c:\\data\\Desert.jpg","\\update\\Desert.jpg") = True Then
   
Messagebox.show("上传完成!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)
Else
   
Messagebox.show("上传失败!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)
End If


--  作者:黄训良
--  发布时间:2016/2/20 22:23:00
--  
Dim ftp1 As New FtpClient
ftp1
.Host="196.128.143.28"
ftp1
.Account = "foxuser"
ftp1
.Password = "138238110"
If ftp1.Connect   ‘判断ftp是否连接成功

  If 
ftp1.Upload("c:\\data\\Desert.jpg","\\update\\Desert.jpg") = True Then
      
Messagebox.show("上传完成!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)
  Else
      
Messagebox.show("上传失败!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)
  End If
Else
   msgbox("FTP连接不成功")
End If
[此贴子已经被作者于2016/2/20 22:24:36编辑过]