Foxtable(狐表)用户栏目专家坐堂 → 文件保存到FTP服务器


  共有2015人关注过本帖树形打印复制链接

主题:文件保存到FTP服务器

帅哥哟,离线,有人找我吗?
yifan3429
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:九尾狐 帖子:2437 积分:22520 威望:0 精华:0 注册:2011/3/29 17:14:00
文件保存到FTP服务器  发帖心情 Post By:2017/12/8 21:36:00 [只看该作者]

If e.Col.name = "图片" Then
    baseMainForm.WindowState= Windows.forms.FormWindowState.Minimized
    ClipBoard.Clear
    Dim proc As new Process
    proc.File = ApplicationPath & "/capture.exe"
    proc.WaitForClose = True
    proc.Start
    If ClipBoard.GetImage IsNot Nothing Then
        Dim f As String =  e.Row("客户名称") & "\"  & e.Row("楼层")& "\"  & "3.报价配图"  & "\" & Format( Date.Today,"yyyy-MM-dd") & "\"& e.Row("产品名") &"-" & e.Row("产品号")&".png"
        Dim path As String = e.Col.DataCol.DefaultFolder
        If path = "" Then
           
            path = Vars("IPM")
            
        End If
        basemainform.WindowState = 2
        Dim dir As String = FileSys.GetParentPath(path & "/" & f)
        If FileSys.DirectoryExists(dir) = False Then FileSys.CreateDirectory(dir)
        ClipBoard.GetImage.save(path & "/" & f)
        e.Row(e.Col.name) = f
    End If
    e.cancel = True
    Tables("订单总表.订单明细").Current.Save() '保存文件的行
    End If

我想将截屏文件直接保存到FTP服务器  可以吗  代码怎样编辑

 回到顶部
帅哥,在线噢!
有点蓝
  2楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:超级版主 帖子:105491 积分:536446 威望:0 精华:9 注册:2015/6/24 9:21:00
  发帖心情 Post By:2017/12/8 22:09:00 [只看该作者]

If e.Col.name = "图片" Then
    baseMainForm.WindowState= Windows.forms.FormWindowState.Minimized
    ClipBoard.Clear
    Dim proc As new Process
    proc.File = ApplicationPath & "/capture.exe"
    proc.WaitForClose = True
    proc.Start
    If ClipBoard.GetImage IsNot Nothing Then
        Dim f As String =  e.Row("客户名称") & "\"  & e.Row("楼层")& "\"  & "3.报价配图"  & "\" & Format( Date.Today,"yyyy-MM-dd") & "\"& e.Row("产品名") &"-" & e.Row("产品号")&".png"
        Dim path As String = e.Col.DataCol.DefaultFolder
        If path = "" Then
            
            path = Vars("IPM")
            
        End If
        basemainform.WindowState = 2
        Dim dir As String = FileSys.GetParentPath(path & "/" & f)
        If FileSys.DirectoryExists(dir) = False Then FileSys.CreateDirectory(dir)
        ClipBoard.GetImage.save(path & "/" & f)
        e.Row(e.Col.name) = f
        Dim  ftp1 As  New  FtpClient
        ftp1.Host="196.128.143.28"
        ftp1.Account =  "foxuser"
        ftp1.Password =  "138238110"
        If  ftp1.Upload(path & "/" & f,f) = True Then
            Messagebox.show("上传完成!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)
        Else
            Messagebox.show("上传失败!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)
        End If
    End If
    e.cancel = True
    Tables("订单总表.订单明细").Current.Save() '保存文件的行
End If

[此贴子已经被作者于2017/12/8 22:10:01编辑过]

 回到顶部
帅哥哟,离线,有人找我吗?
yifan3429
  3楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:九尾狐 帖子:2437 积分:22520 威望:0 精华:0 注册:2011/3/29 17:14:00
  发帖心情 Post By:2017/12/8 22:50:00 [只看该作者]

If e.Col.name = "图片" Then
    baseMainForm.WindowState= Windows.forms.FormWindowState.Minimized
    ClipBoard.Clear
    Dim proc As new Process
    proc.File = ApplicationPath & "/capture.exe"
    proc.WaitForClose = True
    proc.Start
    If ClipBoard.GetImage IsNot Nothing Then
        Dim f As String =  e.Row("客户名称") & "\"  & e.Row("楼层")& "\"  & "3.报价配图"  & "\" & Format( Date.Today,"yyyy-MM-dd") & "\"& e.Row("产品名") &"-" & e.Row("产品号")&".png"
        Dim path As String = e.Col.DataCol.DefaultFolder
        If path = "" Then
            
            path = Vars("IPM")     文件还是存到我的这个本地地址 没有上传到 FTP、
            
        End If
        basemainform.WindowState = 2
        Dim dir As String = FileSys.GetParentPath(path & "/" & f)
        If FileSys.DirectoryExists(dir) = False Then FileSys.CreateDirectory(dir)
        ClipBoard.GetImage.save(path & "/" & f)
        e.Row(e.Col.name) = f
        Dim  ftp1 As  New  FtpClient
        ftp1.Host="196.128.143.28"
        ftp1.Account =  "foxuser"
        ftp1.Password =  "138238110"
        If  ftp1.Upload(path & "/" & f,f) = True Then
            Messagebox.show("上传完成!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)
        Else
            Messagebox.show("上传失败!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)
        End If
    End If
    e.cancel = True
    Tables("订单总表.订单明细").Current.Save() '保存文件的行
End If

 回到顶部
帅哥,在线噢!
有点蓝
  4楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:超级版主 帖子:105491 积分:536446 威望:0 精华:9 注册:2015/6/24 9:21:00
  发帖心情 Post By:2017/12/8 23:02:00 [只看该作者]

改为自己的ftp的地址和用户,以及上传的路径。下面代码运行后提示成功还是失败?

Dim  ftp1 As  New  FtpClient
        ftp1.Host="196.128.143.28"
        ftp1.Account =  "foxuser"
        ftp1.Password =  "138238110"
        If  ftp1.Upload(path & "/" & f,f) = True Then
            Messagebox.show("上传完成!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)
        Else
            Messagebox.show("上传失败!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)
        End If

 回到顶部
帅哥哟,离线,有人找我吗?
yifan3429
  5楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:九尾狐 帖子:2437 积分:22520 威望:0 精华:0 注册:2011/3/29 17:14:00
  发帖心情 Post By:2017/12/8 23:21:00 [只看该作者]

提示失败

 回到顶部
帅哥,在线噢!
有点蓝
  6楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:超级版主 帖子:105491 积分:536446 威望:0 精华:9 注册:2015/6/24 9:21:00
  发帖心情 Post By:2017/12/9 8:37:00 [只看该作者]

直接打开管理器能不能打开?
Dim  ftp1 As  New  FtpClient
ftp1.Host="196.128.143.28"
ftp1.Account =  "foxuser"
ftp1.Password =  "138238110"
ftp1.OpenManager

这样呢?
Dim  ftp1 As  New  FtpClient
ftp1.Host="196.128.143.28"
ftp1.Account =  "foxuser"
ftp1.Password =  "138238110"
If  ftp1.Upload(path & "\" & f, "/" & f) = True Then
    Messagebox.show("上传完成!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)
Else
    Messagebox.show("上传失败!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)
End If

 回到顶部
帅哥哟,离线,有人找我吗?
yifan3429
  7楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:九尾狐 帖子:2437 积分:22520 威望:0 精华:0 注册:2011/3/29 17:14:00
  发帖心情 Post By:2017/12/9 21:24:00 [只看该作者]

地址测试正常  就是提示上传失败

If e.Col.name = "图片" Then
    baseMainForm.WindowState= Windows.forms.FormWindowState.Minimized
    ClipBoard.Clear
    Dim proc As new Process
    proc.File = ApplicationPath & "/capture.exe"
    proc.WaitForClose = True
    proc.Start
    If ClipBoard.GetImage IsNot Nothing Then
        Dim f As String =  e.Row("客户名称") & "\"  & e.Row("楼层")& "\"  & "3.报价配图"  & "\" & Format( Date.Today,"yyyy-MM-dd") & "\"& e.Row("产品名") &"-" & e.Row("产品号")&".png"
        Dim path As String = e.Col.DataCol.DefaultFolder
        If path = "" Then
            
            path = Vars("IPM")   现在文件会存到我这个本地地址  不会上传到ftp
            
        End If
        basemainform.WindowState = 2
        Dim dir As String = FileSys.GetParentPath(path & "/" & f)
        If FileSys.DirectoryExists(dir) = False Then FileSys.CreateDirectory(dir)
        ClipBoard.GetImage.save(path & "/" & f)
        e.Row(e.Col.name) = f
        Dim  ftp1 As  New  FtpClient
        ftp1.Host="47.95.20"
        ftp1.Account =  "foxftp"
        ftp1.Password =  "Yi8"
        If  ftp1.Upload(path & "/" & f,f) = True Then
            
            'If  ftp1.Upload(path & "\" & f, "/" & f) = True Then
            Messagebox.show("上传完成!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)
        Else
            Messagebox.show("上传失败!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)
        End If
    End If
    e.cancel = True
    Tables("订单总表.订单明细").Current.Save() '保存文件的行
End If
[此贴子已经被作者于2017/12/9 21:25:37编辑过]

 回到顶部
帅哥哟,离线,有人找我吗?
有点甜
  8楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:版主 帖子:85326 积分:427815 威望:0 精华:5 注册:2012/10/18 22:13:00
  发帖心情 Post By:2017/12/10 16:08:00 [只看该作者]

路径必须存在才能上传的。如果不存在,必须创建

 


Dim path As String = ""

Dim file As String = e.Row("客户名称") & "\"  & e.Row("楼层")& "\"  & "3.报价配图"  & "\" & Format( Date.Today,"yyyy-MM-dd")
For Each s As String In file.split("\")
    path = path & "/" & s
    If ftp1.DirExists(path) = False Then
        ftp1.MakeDir(path)
    End If
Next

If  ftp1.Upload(path & "/" & f,f) = True Then


 回到顶部
帅哥哟,离线,有人找我吗?
yifan3429
  9楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:九尾狐 帖子:2437 积分:22520 威望:0 精华:0 注册:2011/3/29 17:14:00
  发帖心情 Post By:2017/12/11 13:02:00 [只看该作者]

If e.Col.name = "图片" Then
    baseMainForm.WindowState= Windows.forms.FormWindowState.Minimized
    ClipBoard.Clear
    Dim proc As new Process
    proc.File = ApplicationPath & "/capture.exe"
    proc.WaitForClose = True
    proc.Start
    If ClipBoard.GetImage IsNot Nothing Then
        Dim f As String =  e.Row("客户名称") & "\"  & e.Row("楼层")& "\"  & "3.报价配图"  & "\" & Format( Date.Today,"yyyy-MM-dd") & "\"& e.Row("产品名") &"-" & e.Row("产品号")&".png"
        Dim path As String = e.Col.DataCol.DefaultFolder
        If path = "" Then
            
            path = Vars("IPM")
            
        End If
        basemainform.WindowState = 2
        Dim dir As String = FileSys.GetParentPath(path & "/" & f)
        If FileSys.DirectoryExists(dir) = False Then FileSys.CreateDirectory(dir)
        ClipBoard.GetImage.save(path & "/" & f)
        e.Row(e.Col.name) = f
        Dim  ftp1 As  New  FtpClient
        ftp1.Host="47.0"
        ftp1.Account =  "foftp"
        ftp1.Password =  "Y08"
        Dim path As String = ""
        Dim file As String = e.Row("客户名称") & "\"  & e.Row("楼层")& "\"  & "3.报价配图"  & "\" & Format( Date.Today,"yyyy-MM-dd")
        For Each s As String In file.split("\")
            path = path & "/" & s
            If ftp1.DirExists(path) = False Then
                ftp1.MakeDir(path)
            End If
        Next
        If  ftp1.Upload(path & "/" & f,f) = True Then
            
            'If  ftp1.Upload(path & "\" & f, "/" & f) = True Then
            Messagebox.show("上传完成!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)
        Else
            Messagebox.show("上传失败!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)
        End If
    End If
    e.cancel = True
    Tables("订单总表.订单明细").Current.Save() '保存文件的行
End If

这样吗  就是会同时保存在本地和ftp上

 回到顶部
帅哥哟,离线,有人找我吗?
有点甜
  10楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:版主 帖子:85326 积分:427815 威望:0 精华:5 注册:2012/10/18 22:13:00
  发帖心情 Post By:2017/12/11 14:25:00 [只看该作者]

现在执行同样报错不能上传?下面代码弹出什么?

 

msgbox(ftp1.DirExists("/" & file))

 

msgbox(ftp1.DirExists("/" & file.replace("\", "/")))


 回到顶部
总数 17 1 2 下一页