Advertisement
jamboljack

FTPPUT.prg

Jul 12th, 2014
384
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. **********************************************************************************
  2. *... FTPPut.PRG ...*
  3.  
  4. Parameters lchost, lcuser, lcpassword, lcsource, lctarget, lnxfertype
  5.  
  6. *.................................................................................
  7. *:   Usage: DO ftpput WITH ;
  8. *:         'ftp.host', 'name', 'password', 'source.file', 'target.file'[, 1 | 2]
  9. *:
  10. *:  Where:  lcHost     = Host computer IP address or name
  11. *:          lcUser     = user name - anonymous may be used
  12. *:          lcPassword = password
  13. *:          lcSource   = source file name (remote)
  14. *:          lcTarget   = target file name (local)
  15. *:          lnXFerType = 1 (default) for ascii, 2 for binary
  16. *.................................................................................
  17.  
  18. Declare Integer InternetOpen In wininet.Dll;
  19.     STRING  sAgent,;
  20.     INTEGER lAccessType,;
  21.     STRING  sProxyName,;
  22.     STRING  sProxyBypass,;
  23.     STRING  lFlags
  24.  
  25. Declare Integer InternetCloseHandle In wininet.Dll Integer hInet
  26.  
  27. Declare Integer InternetConnect In wininet.Dll;
  28.     INTEGER hInternetSession,;
  29.     STRING  lcHost,;
  30.     INTEGER nServerPort,;
  31.     STRING  lcUser,;
  32.     STRING  lcPassword,;
  33.     INTEGER lService,;
  34.     INTEGER lFlags,;
  35.     INTEGER lContext
  36.  
  37. Declare Integer FtpPutFile In wininet.Dll;
  38.     INTEGER hConnect,;
  39.     STRING  lpszLocalFile,;
  40.     STRING  lpszNewRemoteFile,;
  41.     INTEGER dwFlags,;
  42.     INTEGER dwContext
  43.  
  44. Declare Integer FtpDeleteFile In wininet.Dll;
  45.     INTEGER hConnect,;
  46.     STRING  lpszFileName
  47.  
  48. Public hopen, hftpsession
  49.  
  50. lchost     = Alltrim(lchost)
  51. lcuser     = Alltrim(lcuser)
  52. lcpassword = Alltrim(lcpassword)
  53. lcsource   = Alltrim(lcsource)
  54. lctarget   = Alltrim(lctarget)
  55.  
  56. If connect2ftp (lchost, lcuser, lcpassword)
  57.     ** Sukses sampai disini
  58.     Wait Window 'Transferring File....' Nowait Nocle
  59.    
  60.     If ftpputfile(hftpsession, lcsource, lctarget, 1, 0) = 1
  61.         Wait Window lcsource + ' File Transferred.' Nowait Nocle
  62.     Else
  63.         Wait Window lcsource + ' File NOT Transferred.' Nowait Nocle
  64.     Endif
  65.  
  66.     = internetclosehandle (hftpsession)
  67.     = internetclosehandle (hopen)
  68.     Wait Clear
  69. Endif
  70.  
  71. *..................... connect2ftp .........................................
  72. *...  Makes sure there is actually a valid connection to the host
  73. Function  connect2ftp (lchost, lcuser, lcpassword)
  74. * open access to Inet functions
  75. hopen = internetopen ("vfp", 1, 0, 0, 0)
  76. If hopen = 0
  77.     Return .F.
  78. Endif
  79.  
  80. *... The first '0' says use the default port, usually 21.
  81. hftpsession = internetconnect (hopen, lchost,;
  82.     0, lcuser, lcpassword, 1, 0, 0)   &&... 1 = ftp protocol
  83. If hftpsession = 0
  84.     * close access to Inet functions and exit
  85.     = internetclosehandle (hopen)
  86.     *!*       ? "ftp " + lcHost + " is not available"
  87.     Return .F.
  88. Else
  89.     *!*       ? "Connected to " + lcHost
  90. Endif
  91. Return .T.
  92. Return
  93. *** End of ftpPut.PRG ***********************************************************
  94. *... FTPPut.PRG ...*
  95.  
  96. Parameters lchost, lcuser, lcpassword, lcsource, lctarget, lnxfertype
  97. *.................................................................................
  98. *:   Usage: DO ftpput WITH ;
  99. *:         'ftp.host', 'name', 'password', 'source.file', 'target.file'[, 1 | 2]
  100. *:
  101. *:  Where:  lcHost     = Host computer IP address or name
  102. *:          lcUser     = user name - anonymous may be used
  103. *:          lcPassword = password
  104. *:          lcSource   = source file name (remote)
  105. *:          lcTarget   = target file name (local)
  106. *:          lnXFerType = 1 (default) for ascii, 2 for binary
  107. *.................................................................................
  108.  
  109. Declare Integer InternetOpen In wininet.Dll;
  110.     STRING  sAgent,;
  111.     INTEGER lAccessType,;
  112.     STRING  sProxyName,;
  113.     STRING  sProxyBypass,;
  114.     STRING  lFlags
  115.  
  116. Declare Integer InternetCloseHandle In wininet.Dll Integer hInet
  117.  
  118. Declare Integer InternetConnect In wininet.Dll;
  119.     INTEGER hInternetSession,;
  120.     STRING  lcHost,;
  121.     INTEGER nServerPort,;
  122.     STRING  lcUser,;
  123.     STRING  lcPassword,;
  124.     INTEGER lService,;
  125.     INTEGER lFlags,;
  126.     INTEGER lContext
  127.  
  128. Declare Integer FtpPutFile In wininet.Dll;
  129.     INTEGER hConnect,;
  130.     STRING  lpszLocalFile,;
  131.     STRING  lpszNewRemoteFile,;
  132.     INTEGER dwFlags,;
  133.     INTEGER dwContext
  134.  
  135. Declare Integer FtpDeleteFile In wininet.Dll;
  136.     INTEGER hConnect,;
  137.     STRING  lpszFileName
  138.  
  139. Public hopen, hftpsession
  140.  
  141. lchost     = Alltrim(lchost)
  142. lcuser     = Alltrim(lcuser)
  143. lcpassword = Alltrim(lcpassword)
  144. lcsource   = Alltrim(lcsource)
  145. lctarget   = Alltrim(lctarget)
  146.  
  147. If connect2ftp (lchost, lcuser, lcpassword)
  148.     ** Sukses sampai disini
  149.     Wait Window 'Transferring File....' Nowait Nocle
  150.    
  151.     If ftpputfile(hftpsession, lcsource, lctarget, 1, 0) = 1
  152.         Wait Window lcsource + ' File Transferred.' Nowait Nocle
  153.     Else
  154.         Wait Window lcsource + ' File NOT Transferred.' Nowait Nocle
  155.     Endif
  156.  
  157.     = internetclosehandle (hftpsession)
  158.     = internetclosehandle (hopen)
  159.     Wait Clear
  160. Endif
  161.  
  162. *..................... connect2ftp .........................................
  163. *...  Makes sure there is actually a valid connection to the host
  164. Function  connect2ftp (lchost, lcuser, lcpassword)
  165. * open access to Inet functions
  166. hopen = internetopen ("vfp", 1, 0, 0, 0)
  167. If hopen = 0
  168.     Return .F.
  169. Endif
  170.  
  171. *... The first '0' says use the default port, usually 21.
  172. hftpsession = internetconnect (hopen, lchost,;
  173.     0, lcuser, lcpassword, 1, 0, 0)   &&... 1 = ftp protocol
  174. If hftpsession = 0
  175.     * close access to Inet functions and exit
  176.     = internetclosehandle (hopen)
  177.     *!*       ? "ftp " + lcHost + " is not available"
  178.     Return .F.
  179. Else
  180.     *!*       ? "Connected to " + lcHost
  181. Endif
  182. Return .T.
  183. Return
  184. *** End of ftpPut.PRG ***********************************************************
  185. *.................................................................................
  186. *:   Usage: DO ftpput WITH ;
  187. *:         'ftp.host', 'name', 'password', 'source.file', 'target.file'[, 1 | 2]
  188. *:
  189. *:  Where:  lcHost     = Host computer IP address or name
  190. *:          lcUser     = user name - anonymous may be used
  191. *:          lcPassword = password
  192. *:          lcSource   = source file name (remote)
  193. *:          lcTarget   = target file name (local)
  194. *:          lnXFerType = 1 (default) for ascii, 2 for binary
  195. *.................................................................................
  196.  
  197. Declare Integer InternetOpen In wininet.Dll;
  198.     STRING  sAgent,;
  199.     INTEGER lAccessType,;
  200.     STRING  sProxyName,;
  201.     STRING  sProxyBypass,;
  202.     STRING  lFlags
  203.  
  204. Declare Integer InternetCloseHandle In wininet.Dll Integer hInet
  205.  
  206. Declare Integer InternetConnect In wininet.Dll;
  207.     INTEGER hInternetSession,;
  208.     STRING  lcHost,;
  209.     INTEGER nServerPort,;
  210.     STRING  lcUser,;
  211.     STRING  lcPassword,;
  212.     INTEGER lService,;
  213.     INTEGER lFlags,;
  214.     INTEGER lContext
  215.  
  216. Declare Integer FtpPutFile In wininet.Dll;
  217.     INTEGER hConnect,;
  218.     STRING  lpszLocalFile,;
  219.     STRING  lpszNewRemoteFile,;
  220.     INTEGER dwFlags,;
  221.     INTEGER dwContext
  222.  
  223. Declare Integer FtpDeleteFile In wininet.Dll;
  224.     INTEGER hConnect,;
  225.     STRING  lpszFileName
  226.  
  227. Public hopen, hftpsession
  228.  
  229. lchost     = Alltrim(lchost)
  230. lcuser     = Alltrim(lcuser)
  231. lcpassword = Alltrim(lcpassword)
  232. lcsource   = Alltrim(lcsource)
  233. lctarget   = Alltrim(lctarget)
  234.  
  235. If connect2ftp (lchost, lcuser, lcpassword)
  236.     ** Sukses sampai disini
  237.     Wait Window 'Transferring File....' Nowait Nocle
  238.    
  239.     If ftpputfile(hftpsession, lcsource, lctarget, 1, 0) = 1
  240.         Wait Window lcsource + ' File Transferred.' Nowait Nocle
  241.     Else
  242.         Wait Window lcsource + ' File NOT Transferred.' Nowait Nocle
  243.     Endif
  244.  
  245.     = internetclosehandle (hftpsession)
  246.     = internetclosehandle (hopen)
  247.     Wait Clear
  248. Endif
  249.  
  250. *..................... connect2ftp .........................................
  251. *...  Makes sure there is actually a valid connection to the host
  252. Function  connect2ftp (lchost, lcuser, lcpassword)
  253. * open access to Inet functions
  254. hopen = internetopen ("vfp", 1, 0, 0, 0)
  255. If hopen = 0
  256.     Return .F.
  257. Endif
  258.  
  259. *... The first '0' says use the default port, usually 21.
  260. hftpsession = internetconnect (hopen, lchost,;
  261.     0, lcuser, lcpassword, 1, 0, 0)   &&... 1 = ftp protocol
  262. If hftpsession = 0
  263.     * close access to Inet functions and exit
  264.     = internetclosehandle (hopen)
  265.     *!*       ? "ftp " + lcHost + " is not available"
  266.     Return .F.
  267. Else
  268.     *!*       ? "Connected to " + lcHost
  269. Endif
  270. Return .T.
  271. Return
  272. *** End of ftpPut.PRG ***********************************************************
  273. *:   Usage: DO ftpput WITH ;
  274. *:         'ftp.host', 'name', 'password', 'source.file', 'target.file'[, 1 | 2]
  275. *:
  276. *:  Where:  lcHost     = Host computer IP address or name
  277. *:          lcUser     = user name - anonymous may be used
  278. *:          lcPassword = password
  279. *:          lcSource   = source file name (remote)
  280. *:          lcTarget   = target file name (local)
  281. *:          lnXFerType = 1 (default) for ascii, 2 for binary
  282. *.................................................................................
  283.  
  284. Declare Integer InternetOpen In wininet.Dll;
  285.     STRING  sAgent,;
  286.     INTEGER lAccessType,;
  287.     STRING  sProxyName,;
  288.     STRING  sProxyBypass,;
  289.     STRING  lFlags
  290.  
  291. Declare Integer InternetCloseHandle In wininet.Dll Integer hInet
  292.  
  293. Declare Integer InternetConnect In wininet.Dll;
  294.     INTEGER hInternetSession,;
  295.     STRING  lcHost,;
  296.     INTEGER nServerPort,;
  297.     STRING  lcUser,;
  298.     STRING  lcPassword,;
  299.     INTEGER lService,;
  300.     INTEGER lFlags,;
  301.     INTEGER lContext
  302.  
  303. Declare Integer FtpPutFile In wininet.Dll;
  304.     INTEGER hConnect,;
  305.     STRING  lpszLocalFile,;
  306.     STRING  lpszNewRemoteFile,;
  307.     INTEGER dwFlags,;
  308.     INTEGER dwContext
  309.  
  310. Declare Integer FtpDeleteFile In wininet.Dll;
  311.     INTEGER hConnect,;
  312.     STRING  lpszFileName
  313.  
  314. Public hopen, hftpsession
  315.  
  316. lchost     = Alltrim(lchost)
  317. lcuser     = Alltrim(lcuser)
  318. lcpassword = Alltrim(lcpassword)
  319. lcsource   = Alltrim(lcsource)
  320. lctarget   = Alltrim(lctarget)
  321.  
  322. If connect2ftp (lchost, lcuser, lcpassword)
  323.     ** Sukses sampai disini
  324.     Wait Window 'Transferring File....' Nowait Nocle
  325.    
  326.     If ftpputfile(hftpsession, lcsource, lctarget, 1, 0) = 1
  327.         Wait Window lcsource + ' File Transferred.' Nowait Nocle
  328.     Else
  329.         Wait Window lcsource + ' File NOT Transferred.' Nowait Nocle
  330.     Endif
  331.  
  332.     = internetclosehandle (hftpsession)
  333.     = internetclosehandle (hopen)
  334.     Wait Clear
  335. Endif
  336.  
  337. *..................... connect2ftp .........................................
  338. *...  Makes sure there is actually a valid connection to the host
  339. Function  connect2ftp (lchost, lcuser, lcpassword)
  340. * open access to Inet functions
  341. hopen = internetopen ("vfp", 1, 0, 0, 0)
  342. If hopen = 0
  343.     Return .F.
  344. Endif
  345.  
  346. *... The first '0' says use the default port, usually 21.
  347. hftpsession = internetconnect (hopen, lchost,;
  348.     0, lcuser, lcpassword, 1, 0, 0)   &&... 1 = ftp protocol
  349. If hftpsession = 0
  350.     * close access to Inet functions and exit
  351.     = internetclosehandle (hopen)
  352.     *!*       ? "ftp " + lcHost + " is not available"
  353.     Return .F.
  354. Else
  355.     *!*       ? "Connected to " + lcHost
  356. Endif
  357. Return .T.
  358. Return
  359. *** End of ftpPut.PRG ***********************************************************
  360. *:         'ftp.host', 'name', 'password', 'source.file', 'target.file'[, 1 | 2]
  361. *:
  362. *:  Where:  lcHost     = Host computer IP address or name
  363. *:          lcUser     = user name - anonymous may be used
  364. *:          lcPassword = password
  365. *:          lcSource   = source file name (remote)
  366. *:          lcTarget   = target file name (local)
  367. *:          lnXFerType = 1 (default) for ascii, 2 for binary
  368. *.................................................................................
  369.  
  370. Declare Integer InternetOpen In wininet.Dll;
  371.     STRING  sAgent,;
  372.     INTEGER lAccessType,;
  373.     STRING  sProxyName,;
  374.     STRING  sProxyBypass,;
  375.     STRING  lFlags
  376.  
  377. Declare Integer InternetCloseHandle In wininet.Dll Integer hInet
  378.  
  379. Declare Integer InternetConnect In wininet.Dll;
  380.     INTEGER hInternetSession,;
  381.     STRING  lcHost,;
  382.     INTEGER nServerPort,;
  383.     STRING  lcUser,;
  384.     STRING  lcPassword,;
  385.     INTEGER lService,;
  386.     INTEGER lFlags,;
  387.     INTEGER lContext
  388.  
  389. Declare Integer FtpPutFile In wininet.Dll;
  390.     INTEGER hConnect,;
  391.     STRING  lpszLocalFile,;
  392.     STRING  lpszNewRemoteFile,;
  393.     INTEGER dwFlags,;
  394.     INTEGER dwContext
  395.  
  396. Declare Integer FtpDeleteFile In wininet.Dll;
  397.     INTEGER hConnect,;
  398.     STRING  lpszFileName
  399.  
  400. Public hopen, hftpsession
  401.  
  402. lchost     = Alltrim(lchost)
  403. lcuser     = Alltrim(lcuser)
  404. lcpassword = Alltrim(lcpassword)
  405. lcsource   = Alltrim(lcsource)
  406. lctarget   = Alltrim(lctarget)
  407.  
  408. If connect2ftp (lchost, lcuser, lcpassword)
  409.     ** Sukses sampai disini
  410.     Wait Window 'Transferring File....' Nowait Nocle
  411.    
  412.     If ftpputfile(hftpsession, lcsource, lctarget, 1, 0) = 1
  413.         Wait Window lcsource + ' File Transferred.' Nowait Nocle
  414.     Else
  415.         Wait Window lcsource + ' File NOT Transferred.' Nowait Nocle
  416.     Endif
  417.  
  418.     = internetclosehandle (hftpsession)
  419.     = internetclosehandle (hopen)
  420.     Wait Clear
  421. Endif
  422.  
  423. *..................... connect2ftp .........................................
  424. *...  Makes sure there is actually a valid connection to the host
  425. Function  connect2ftp (lchost, lcuser, lcpassword)
  426. * open access to Inet functions
  427. hopen = internetopen ("vfp", 1, 0, 0, 0)
  428. If hopen = 0
  429.     Return .F.
  430. Endif
  431.  
  432. *... The first '0' says use the default port, usually 21.
  433. hftpsession = internetconnect (hopen, lchost,;
  434.     0, lcuser, lcpassword, 1, 0, 0)   &&... 1 = ftp protocol
  435. If hftpsession = 0
  436.     * close access to Inet functions and exit
  437.     = internetclosehandle (hopen)
  438.     *!*       ? "ftp " + lcHost + " is not available"
  439.     Return .F.
  440. Else
  441.     *!*       ? "Connected to " + lcHost
  442. Endif
  443. Return .T.
  444. Return
  445. *** End of ftpPut.PRG ***********************************************************
  446. *:
  447. *:  Where:  lcHost     = Host computer IP address or name
  448. *:          lcUser     = user name - anonymous may be used
  449. *:          lcPassword = password
  450. *:          lcSource   = source file name (remote)
  451. *:          lcTarget   = target file name (local)
  452. *:          lnXFerType = 1 (default) for ascii, 2 for binary
  453. *.................................................................................
  454.  
  455. Declare Integer InternetOpen In wininet.Dll;
  456.     STRING  sAgent,;
  457.     INTEGER lAccessType,;
  458.     STRING  sProxyName,;
  459.     STRING  sProxyBypass,;
  460.     STRING  lFlags
  461.  
  462. Declare Integer InternetCloseHandle In wininet.Dll Integer hInet
  463.  
  464. Declare Integer InternetConnect In wininet.Dll;
  465.     INTEGER hInternetSession,;
  466.     STRING  lcHost,;
  467.     INTEGER nServerPort,;
  468.     STRING  lcUser,;
  469.     STRING  lcPassword,;
  470.     INTEGER lService,;
  471.     INTEGER lFlags,;
  472.     INTEGER lContext
  473.  
  474. Declare Integer FtpPutFile In wininet.Dll;
  475.     INTEGER hConnect,;
  476.     STRING  lpszLocalFile,;
  477.     STRING  lpszNewRemoteFile,;
  478.     INTEGER dwFlags,;
  479.     INTEGER dwContext
  480.  
  481. Declare Integer FtpDeleteFile In wininet.Dll;
  482.     INTEGER hConnect,;
  483.     STRING  lpszFileName
  484.  
  485. Public hopen, hftpsession
  486.  
  487. lchost     = Alltrim(lchost)
  488. lcuser     = Alltrim(lcuser)
  489. lcpassword = Alltrim(lcpassword)
  490. lcsource   = Alltrim(lcsource)
  491. lctarget   = Alltrim(lctarget)
  492.  
  493. If connect2ftp (lchost, lcuser, lcpassword)
  494.     ** Sukses sampai disini
  495.     Wait Window 'Transferring File....' Nowait Nocle
  496.    
  497.     If ftpputfile(hftpsession, lcsource, lctarget, 1, 0) = 1
  498.         Wait Window lcsource + ' File Transferred.' Nowait Nocle
  499.     Else
  500.         Wait Window lcsource + ' File NOT Transferred.' Nowait Nocle
  501.     Endif
  502.  
  503.     = internetclosehandle (hftpsession)
  504.     = internetclosehandle (hopen)
  505.     Wait Clear
  506. Endif
  507.  
  508. *..................... connect2ftp .........................................
  509. *...  Makes sure there is actually a valid connection to the host
  510. Function  connect2ftp (lchost, lcuser, lcpassword)
  511. * open access to Inet functions
  512. hopen = internetopen ("vfp", 1, 0, 0, 0)
  513. If hopen = 0
  514.     Return .F.
  515. Endif
  516.  
  517. *... The first '0' says use the default port, usually 21.
  518. hftpsession = internetconnect (hopen, lchost,;
  519.     0, lcuser, lcpassword, 1, 0, 0)   &&... 1 = ftp protocol
  520. If hftpsession = 0
  521.     * close access to Inet functions and exit
  522.     = internetclosehandle (hopen)
  523.     *!*       ? "ftp " + lcHost + " is not available"
  524.     Return .F.
  525. Else
  526.     *!*       ? "Connected to " + lcHost
  527. Endif
  528. Return .T.
  529. Return
  530. *** End of ftpPut.PRG ***********************************************************
  531. *:  Where:  lcHost     = Host computer IP address or name
  532. *:          lcUser     = user name - anonymous may be used
  533. *:          lcPassword = password
  534. *:          lcSource   = source file name (remote)
  535. *:          lcTarget   = target file name (local)
  536. *:          lnXFerType = 1 (default) for ascii, 2 for binary
  537. *.................................................................................
  538.  
  539. Declare Integer InternetOpen In wininet.Dll;
  540.     STRING  sAgent,;
  541.     INTEGER lAccessType,;
  542.     STRING  sProxyName,;
  543.     STRING  sProxyBypass,;
  544.     STRING  lFlags
  545.  
  546. Declare Integer InternetCloseHandle In wininet.Dll Integer hInet
  547.  
  548. Declare Integer InternetConnect In wininet.Dll;
  549.     INTEGER hInternetSession,;
  550.     STRING  lcHost,;
  551.     INTEGER nServerPort,;
  552.     STRING  lcUser,;
  553.     STRING  lcPassword,;
  554.     INTEGER lService,;
  555.     INTEGER lFlags,;
  556.     INTEGER lContext
  557.  
  558. Declare Integer FtpPutFile In wininet.Dll;
  559.     INTEGER hConnect,;
  560.     STRING  lpszLocalFile,;
  561.     STRING  lpszNewRemoteFile,;
  562.     INTEGER dwFlags,;
  563.     INTEGER dwContext
  564.  
  565. Declare Integer FtpDeleteFile In wininet.Dll;
  566.     INTEGER hConnect,;
  567.     STRING  lpszFileName
  568.  
  569. Public hopen, hftpsession
  570.  
  571. lchost     = Alltrim(lchost)
  572. lcuser     = Alltrim(lcuser)
  573. lcpassword = Alltrim(lcpassword)
  574. lcsource   = Alltrim(lcsource)
  575. lctarget   = Alltrim(lctarget)
  576.  
  577. If connect2ftp (lchost, lcuser, lcpassword)
  578.     ** Sukses sampai disini
  579.     Wait Window 'Transferring File....' Nowait Nocle
  580.    
  581.     If ftpputfile(hftpsession, lcsource, lctarget, 1, 0) = 1
  582.         Wait Window lcsource + ' File Transferred.' Nowait Nocle
  583.     Else
  584.         Wait Window lcsource + ' File NOT Transferred.' Nowait Nocle
  585.     Endif
  586.  
  587.     = internetclosehandle (hftpsession)
  588.     = internetclosehandle (hopen)
  589.     Wait Clear
  590. Endif
  591.  
  592. *..................... connect2ftp .........................................
  593. *...  Makes sure there is actually a valid connection to the host
  594. Function  connect2ftp (lchost, lcuser, lcpassword)
  595. * open access to Inet functions
  596. hopen = internetopen ("vfp", 1, 0, 0, 0)
  597. If hopen = 0
  598.     Return .F.
  599. Endif
  600.  
  601. *... The first '0' says use the default port, usually 21.
  602. hftpsession = internetconnect (hopen, lchost,;
  603.     0, lcuser, lcpassword, 1, 0, 0)   &&... 1 = ftp protocol
  604. If hftpsession = 0
  605.     * close access to Inet functions and exit
  606.     = internetclosehandle (hopen)
  607.     *!*       ? "ftp " + lcHost + " is not available"
  608.     Return .F.
  609. Else
  610.     *!*       ? "Connected to " + lcHost
  611. Endif
  612. Return .T.
  613. Return
  614. *** End of ftpPut.PRG ***********************************************************
  615. *:          lcUser     = user name - anonymous may be used
  616. *:          lcPassword = password
  617. *:          lcSource   = source file name (remote)
  618. *:          lcTarget   = target file name (local)
  619. *:          lnXFerType = 1 (default) for ascii, 2 for binary
  620. *.................................................................................
  621.  
  622. Declare Integer InternetOpen In wininet.Dll;
  623.     STRING  sAgent,;
  624.     INTEGER lAccessType,;
  625.     STRING  sProxyName,;
  626.     STRING  sProxyBypass,;
  627.     STRING  lFlags
  628.  
  629. Declare Integer InternetCloseHandle In wininet.Dll Integer hInet
  630.  
  631. Declare Integer InternetConnect In wininet.Dll;
  632.     INTEGER hInternetSession,;
  633.     STRING  lcHost,;
  634.     INTEGER nServerPort,;
  635.     STRING  lcUser,;
  636.     STRING  lcPassword,;
  637.     INTEGER lService,;
  638.     INTEGER lFlags,;
  639.     INTEGER lContext
  640.  
  641. Declare Integer FtpPutFile In wininet.Dll;
  642.     INTEGER hConnect,;
  643.     STRING  lpszLocalFile,;
  644.     STRING  lpszNewRemoteFile,;
  645.     INTEGER dwFlags,;
  646.     INTEGER dwContext
  647.  
  648. Declare Integer FtpDeleteFile In wininet.Dll;
  649.     INTEGER hConnect,;
  650.     STRING  lpszFileName
  651.  
  652. Public hopen, hftpsession
  653.  
  654. lchost     = Alltrim(lchost)
  655. lcuser     = Alltrim(lcuser)
  656. lcpassword = Alltrim(lcpassword)
  657. lcsource   = Alltrim(lcsource)
  658. lctarget   = Alltrim(lctarget)
  659.  
  660. If connect2ftp (lchost, lcuser, lcpassword)
  661.     ** Sukses sampai disini
  662.     Wait Window 'Transferring File....' Nowait Nocle
  663.    
  664.     If ftpputfile(hftpsession, lcsource, lctarget, 1, 0) = 1
  665.         Wait Window lcsource + ' File Transferred.' Nowait Nocle
  666.     Else
  667.         Wait Window lcsource + ' File NOT Transferred.' Nowait Nocle
  668.     Endif
  669.  
  670.     = internetclosehandle (hftpsession)
  671.     = internetclosehandle (hopen)
  672.     Wait Clear
  673. Endif
  674.  
  675. *..................... connect2ftp .........................................
  676. *...  Makes sure there is actually a valid connection to the host
  677. Function  connect2ftp (lchost, lcuser, lcpassword)
  678. * open access to Inet functions
  679. hopen = internetopen ("vfp", 1, 0, 0, 0)
  680. If hopen = 0
  681.     Return .F.
  682. Endif
  683.  
  684. *... The first '0' says use the default port, usually 21.
  685. hftpsession = internetconnect (hopen, lchost,;
  686.     0, lcuser, lcpassword, 1, 0, 0)   &&... 1 = ftp protocol
  687. If hftpsession = 0
  688.     * close access to Inet functions and exit
  689.     = internetclosehandle (hopen)
  690.     *!*       ? "ftp " + lcHost + " is not available"
  691.     Return .F.
  692. Else
  693.     *!*       ? "Connected to " + lcHost
  694. Endif
  695. Return .T.
  696. Return
  697. *** End of ftpPut.PRG ***********************************************************
  698. *:          lcPassword = password
  699. *:          lcSource   = source file name (remote)
  700. *:          lcTarget   = target file name (local)
  701. *:          lnXFerType = 1 (default) for ascii, 2 for binary
  702. *.................................................................................
  703.  
  704. Declare Integer InternetOpen In wininet.Dll;
  705.     STRING  sAgent,;
  706.     INTEGER lAccessType,;
  707.     STRING  sProxyName,;
  708.     STRING  sProxyBypass,;
  709.     STRING  lFlags
  710.  
  711. Declare Integer InternetCloseHandle In wininet.Dll Integer hInet
  712.  
  713. Declare Integer InternetConnect In wininet.Dll;
  714.     INTEGER hInternetSession,;
  715.     STRING  lcHost,;
  716.     INTEGER nServerPort,;
  717.     STRING  lcUser,;
  718.     STRING  lcPassword,;
  719.     INTEGER lService,;
  720.     INTEGER lFlags,;
  721.     INTEGER lContext
  722.  
  723. Declare Integer FtpPutFile In wininet.Dll;
  724.     INTEGER hConnect,;
  725.     STRING  lpszLocalFile,;
  726.     STRING  lpszNewRemoteFile,;
  727.     INTEGER dwFlags,;
  728.     INTEGER dwContext
  729.  
  730. Declare Integer FtpDeleteFile In wininet.Dll;
  731.     INTEGER hConnect,;
  732.     STRING  lpszFileName
  733.  
  734. Public hopen, hftpsession
  735.  
  736. lchost     = Alltrim(lchost)
  737. lcuser     = Alltrim(lcuser)
  738. lcpassword = Alltrim(lcpassword)
  739. lcsource   = Alltrim(lcsource)
  740. lctarget   = Alltrim(lctarget)
  741.  
  742. If connect2ftp (lchost, lcuser, lcpassword)
  743.     ** Sukses sampai disini
  744.     Wait Window 'Transferring File....' Nowait Nocle
  745.    
  746.     If ftpputfile(hftpsession, lcsource, lctarget, 1, 0) = 1
  747.         Wait Window lcsource + ' File Transferred.' Nowait Nocle
  748.     Else
  749.         Wait Window lcsource + ' File NOT Transferred.' Nowait Nocle
  750.     Endif
  751.  
  752.     = internetclosehandle (hftpsession)
  753.     = internetclosehandle (hopen)
  754.     Wait Clear
  755. Endif
  756.  
  757. *..................... connect2ftp .........................................
  758. *...  Makes sure there is actually a valid connection to the host
  759. Function  connect2ftp (lchost, lcuser, lcpassword)
  760. * open access to Inet functions
  761. hopen = internetopen ("vfp", 1, 0, 0, 0)
  762. If hopen = 0
  763.     Return .F.
  764. Endif
  765.  
  766. *... The first '0' says use the default port, usually 21.
  767. hftpsession = internetconnect (hopen, lchost,;
  768.     0, lcuser, lcpassword, 1, 0, 0)   &&... 1 = ftp protocol
  769. If hftpsession = 0
  770.     * close access to Inet functions and exit
  771.     = internetclosehandle (hopen)
  772.     *!*       ? "ftp " + lcHost + " is not available"
  773.     Return .F.
  774. Else
  775.     *!*       ? "Connected to " + lcHost
  776. Endif
  777. Return .T.
  778. Return
  779. *** End of ftpPut.PRG ***********************************************************
  780. *:          lcSource   = source file name (remote)
  781. *:          lcTarget   = target file name (local)
  782. *:          lnXFerType = 1 (default) for ascii, 2 for binary
  783. *.................................................................................
  784.  
  785. Declare Integer InternetOpen In wininet.Dll;
  786.     STRING  sAgent,;
  787.     INTEGER lAccessType,;
  788.     STRING  sProxyName,;
  789.     STRING  sProxyBypass,;
  790.     STRING  lFlags
  791.  
  792. Declare Integer InternetCloseHandle In wininet.Dll Integer hInet
  793.  
  794. Declare Integer InternetConnect In wininet.Dll;
  795.     INTEGER hInternetSession,;
  796.     STRING  lcHost,;
  797.     INTEGER nServerPort,;
  798.     STRING  lcUser,;
  799.     STRING  lcPassword,;
  800.     INTEGER lService,;
  801.     INTEGER lFlags,;
  802.     INTEGER lContext
  803.  
  804. Declare Integer FtpPutFile In wininet.Dll;
  805.     INTEGER hConnect,;
  806.     STRING  lpszLocalFile,;
  807.     STRING  lpszNewRemoteFile,;
  808.     INTEGER dwFlags,;
  809.     INTEGER dwContext
  810.  
  811. Declare Integer FtpDeleteFile In wininet.Dll;
  812.     INTEGER hConnect,;
  813.     STRING  lpszFileName
  814.  
  815. Public hopen, hftpsession
  816.  
  817. lchost     = Alltrim(lchost)
  818. lcuser     = Alltrim(lcuser)
  819. lcpassword = Alltrim(lcpassword)
  820. lcsource   = Alltrim(lcsource)
  821. lctarget   = Alltrim(lctarget)
  822.  
  823. If connect2ftp (lchost, lcuser, lcpassword)
  824.     ** Sukses sampai disini
  825.     Wait Window 'Transferring File....' Nowait Nocle
  826.    
  827.     If ftpputfile(hftpsession, lcsource, lctarget, 1, 0) = 1
  828.         Wait Window lcsource + ' File Transferred.' Nowait Nocle
  829.     Else
  830.         Wait Window lcsource + ' File NOT Transferred.' Nowait Nocle
  831.     Endif
  832.  
  833.     = internetclosehandle (hftpsession)
  834.     = internetclosehandle (hopen)
  835.     Wait Clear
  836. Endif
  837.  
  838. *..................... connect2ftp .........................................
  839. *...  Makes sure there is actually a valid connection to the host
  840. Function  connect2ftp (lchost, lcuser, lcpassword)
  841. * open access to Inet functions
  842. hopen = internetopen ("vfp", 1, 0, 0, 0)
  843. If hopen = 0
  844.     Return .F.
  845. Endif
  846.  
  847. *... The first '0' says use the default port, usually 21.
  848. hftpsession = internetconnect (hopen, lchost,;
  849.     0, lcuser, lcpassword, 1, 0, 0)   &&... 1 = ftp protocol
  850. If hftpsession = 0
  851.     * close access to Inet functions and exit
  852.     = internetclosehandle (hopen)
  853.     *!*       ? "ftp " + lcHost + " is not available"
  854.     Return .F.
  855. Else
  856.     *!*       ? "Connected to " + lcHost
  857. Endif
  858. Return .T.
  859. Return
  860. *** End of ftpPut.PRG ***********************************************************
  861. *:          lcTarget   = target file name (local)
  862. *:          lnXFerType = 1 (default) for ascii, 2 for binary
  863. *.................................................................................
  864.  
  865. Declare Integer InternetOpen In wininet.Dll;
  866.     STRING  sAgent,;
  867.     INTEGER lAccessType,;
  868.     STRING  sProxyName,;
  869.     STRING  sProxyBypass,;
  870.     STRING  lFlags
  871.  
  872. Declare Integer InternetCloseHandle In wininet.Dll Integer hInet
  873.  
  874. Declare Integer InternetConnect In wininet.Dll;
  875.     INTEGER hInternetSession,;
  876.     STRING  lcHost,;
  877.     INTEGER nServerPort,;
  878.     STRING  lcUser,;
  879.     STRING  lcPassword,;
  880.     INTEGER lService,;
  881.     INTEGER lFlags,;
  882.     INTEGER lContext
  883.  
  884. Declare Integer FtpPutFile In wininet.Dll;
  885.     INTEGER hConnect,;
  886.     STRING  lpszLocalFile,;
  887.     STRING  lpszNewRemoteFile,;
  888.     INTEGER dwFlags,;
  889.     INTEGER dwContext
  890.  
  891. Declare Integer FtpDeleteFile In wininet.Dll;
  892.     INTEGER hConnect,;
  893.     STRING  lpszFileName
  894.  
  895. Public hopen, hftpsession
  896.  
  897. lchost     = Alltrim(lchost)
  898. lcuser     = Alltrim(lcuser)
  899. lcpassword = Alltrim(lcpassword)
  900. lcsource   = Alltrim(lcsource)
  901. lctarget   = Alltrim(lctarget)
  902.  
  903. If connect2ftp (lchost, lcuser, lcpassword)
  904.     ** Sukses sampai disini
  905.     Wait Window 'Transferring File....' Nowait Nocle
  906.    
  907.     If ftpputfile(hftpsession, lcsource, lctarget, 1, 0) = 1
  908.         Wait Window lcsource + ' File Transferred.' Nowait Nocle
  909.     Else
  910.         Wait Window lcsource + ' File NOT Transferred.' Nowait Nocle
  911.     Endif
  912.  
  913.     = internetclosehandle (hftpsession)
  914.     = internetclosehandle (hopen)
  915.     Wait Clear
  916. Endif
  917.  
  918. *..................... connect2ftp .........................................
  919. *...  Makes sure there is actually a valid connection to the host
  920. Function  connect2ftp (lchost, lcuser, lcpassword)
  921. * open access to Inet functions
  922. hopen = internetopen ("vfp", 1, 0, 0, 0)
  923. If hopen = 0
  924.     Return .F.
  925. Endif
  926.  
  927. *... The first '0' says use the default port, usually 21.
  928. hftpsession = internetconnect (hopen, lchost,;
  929.     0, lcuser, lcpassword, 1, 0, 0)   &&... 1 = ftp protocol
  930. If hftpsession = 0
  931.     * close access to Inet functions and exit
  932.     = internetclosehandle (hopen)
  933.     *!*       ? "ftp " + lcHost + " is not available"
  934.     Return .F.
  935. Else
  936.     *!*       ? "Connected to " + lcHost
  937. Endif
  938. Return .T.
  939. Return
  940. *** End of ftpPut.PRG ***********************************************************
  941. *:          lnXFerType = 1 (default) for ascii, 2 for binary
  942. *.................................................................................
  943.  
  944. Declare Integer InternetOpen In wininet.Dll;
  945.     STRING  sAgent,;
  946.     INTEGER lAccessType,;
  947.     STRING  sProxyName,;
  948.     STRING  sProxyBypass,;
  949.     STRING  lFlags
  950.  
  951. Declare Integer InternetCloseHandle In wininet.Dll Integer hInet
  952.  
  953. Declare Integer InternetConnect In wininet.Dll;
  954.     INTEGER hInternetSession,;
  955.     STRING  lcHost,;
  956.     INTEGER nServerPort,;
  957.     STRING  lcUser,;
  958.     STRING  lcPassword,;
  959.     INTEGER lService,;
  960.     INTEGER lFlags,;
  961.     INTEGER lContext
  962.  
  963. Declare Integer FtpPutFile In wininet.Dll;
  964.     INTEGER hConnect,;
  965.     STRING  lpszLocalFile,;
  966.     STRING  lpszNewRemoteFile,;
  967.     INTEGER dwFlags,;
  968.     INTEGER dwContext
  969.  
  970. Declare Integer FtpDeleteFile In wininet.Dll;
  971.     INTEGER hConnect,;
  972.     STRING  lpszFileName
  973.  
  974. Public hopen, hftpsession
  975.  
  976. lchost     = Alltrim(lchost)
  977. lcuser     = Alltrim(lcuser)
  978. lcpassword = Alltrim(lcpassword)
  979. lcsource   = Alltrim(lcsource)
  980. lctarget   = Alltrim(lctarget)
  981.  
  982. If connect2ftp (lchost, lcuser, lcpassword)
  983.     ** Sukses sampai disini
  984.     Wait Window 'Transferring File....' Nowait Nocle
  985.    
  986.     If ftpputfile(hftpsession, lcsource, lctarget, 1, 0) = 1
  987.         Wait Window lcsource + ' File Transferred.' Nowait Nocle
  988.     Else
  989.         Wait Window lcsource + ' File NOT Transferred.' Nowait Nocle
  990.     Endif
  991.  
  992.     = internetclosehandle (hftpsession)
  993.     = internetclosehandle (hopen)
  994.     Wait Clear
  995. Endif
  996.  
  997. *..................... connect2ftp .........................................
  998. *...  Makes sure there is actually a valid connection to the host
  999. Function  connect2ftp (lchost, lcuser, lcpassword)
  1000. * open access to Inet functions
  1001. hopen = internetopen ("vfp", 1, 0, 0, 0)
  1002. If hopen = 0
  1003.     Return .F.
  1004. Endif
  1005.  
  1006. *... The first '0' says use the default port, usually 21.
  1007. hftpsession = internetconnect (hopen, lchost,;
  1008.     0, lcuser, lcpassword, 1, 0, 0)   &&... 1 = ftp protocol
  1009. If hftpsession = 0
  1010.     * close access to Inet functions and exit
  1011.     = internetclosehandle (hopen)
  1012.     *!*       ? "ftp " + lcHost + " is not available"
  1013.     Return .F.
  1014. Else
  1015.     *!*       ? "Connected to " + lcHost
  1016. Endif
  1017. Return .T.
  1018. Return
  1019. *** End of ftpPut.PRG ***********************************************************
  1020. *.................................................................................
  1021.  
  1022. Declare Integer InternetOpen In wininet.Dll;
  1023.     STRING  sAgent,;
  1024.     INTEGER lAccessType,;
  1025.     STRING  sProxyName,;
  1026.     STRING  sProxyBypass,;
  1027.     STRING  lFlags
  1028.  
  1029. Declare Integer InternetCloseHandle In wininet.Dll Integer hInet
  1030.  
  1031. Declare Integer InternetConnect In wininet.Dll;
  1032.     INTEGER hInternetSession,;
  1033.     STRING  lcHost,;
  1034.     INTEGER nServerPort,;
  1035.     STRING  lcUser,;
  1036.     STRING  lcPassword,;
  1037.     INTEGER lService,;
  1038.     INTEGER lFlags,;
  1039.     INTEGER lContext
  1040.  
  1041. Declare Integer FtpPutFile In wininet.Dll;
  1042.     INTEGER hConnect,;
  1043.     STRING  lpszLocalFile,;
  1044.     STRING  lpszNewRemoteFile,;
  1045.     INTEGER dwFlags,;
  1046.     INTEGER dwContext
  1047.  
  1048. Declare Integer FtpDeleteFile In wininet.Dll;
  1049.     INTEGER hConnect,;
  1050.     STRING  lpszFileName
  1051.  
  1052. Public hopen, hftpsession
  1053.  
  1054. lchost     = Alltrim(lchost)
  1055. lcuser     = Alltrim(lcuser)
  1056. lcpassword = Alltrim(lcpassword)
  1057. lcsource   = Alltrim(lcsource)
  1058. lctarget   = Alltrim(lctarget)
  1059.  
  1060. If connect2ftp (lchost, lcuser, lcpassword)
  1061.     ** Sukses sampai disini
  1062.     Wait Window 'Transferring File....' Nowait Nocle
  1063.    
  1064.     If ftpputfile(hftpsession, lcsource, lctarget, 1, 0) = 1
  1065.         Wait Window lcsource + ' File Transferred.' Nowait Nocle
  1066.     Else
  1067.         Wait Window lcsource + ' File NOT Transferred.' Nowait Nocle
  1068.     Endif
  1069.  
  1070.     = internetclosehandle (hftpsession)
  1071.     = internetclosehandle (hopen)
  1072.     Wait Clear
  1073. Endif
  1074. *..................... connect2ftp .........................................
  1075. *...  Makes sure there is actually a valid connection to the host
  1076. Function  connect2ftp (lchost, lcuser, lcpassword)
  1077. * open access to Inet functions
  1078. hopen = internetopen ("vfp", 1, 0, 0, 0)
  1079. If hopen = 0
  1080.     Return .F.
  1081. Endif
  1082.  
  1083. *... The first '0' says use the default port, usually 21.
  1084. hftpsession = internetconnect (hopen, lchost,;
  1085.     0, lcuser, lcpassword, 1, 0, 0)   &&... 1 = ftp protocol
  1086. If hftpsession = 0
  1087.     * close access to Inet functions and exit
  1088.     = internetclosehandle (hopen)
  1089.     *!*       ? "ftp " + lcHost + " is not available"
  1090.     Return .F.
  1091. Else
  1092.     *!*       ? "Connected to " + lcHost
  1093. Endif
  1094. Return .T.
  1095. Return
  1096. *** End of ftpPut.PRG ***********************************************************
  1097. *..................... connect2ftp .........................................
  1098. *...  Makes sure there is actually a valid connection to the host
  1099. Function  connect2ftp (lchost, lcuser, lcpassword)
  1100. * open access to Inet functions
  1101. hopen = internetopen ("vfp", 1, 0, 0, 0)
  1102. If hopen = 0
  1103.     Return .F.
  1104. Endif
  1105.  
  1106. *... The first '0' says use the default port, usually 21.
  1107. hftpsession = internetconnect (hopen, lchost,;
  1108.     0, lcuser, lcpassword, 1, 0, 0)   &&... 1 = ftp protocol
  1109. If hftpsession = 0
  1110.     * close access to Inet functions and exit
  1111.     = internetclosehandle (hopen)
  1112.     *!*       ? "ftp " + lcHost + " is not available"
  1113.     Return .F.
  1114. Else
  1115.     *!*       ? "Connected to " + lcHost
  1116. Endif
  1117. Return .T.
  1118. Return
  1119. *** End of ftpPut.PRG ***********************************************************
  1120. *...  Makes sure there is actually a valid connection to the host
  1121. Function  connect2ftp (lchost, lcuser, lcpassword)
  1122. * open access to Inet functions
  1123. hopen = internetopen ("vfp", 1, 0, 0, 0)
  1124. If hopen = 0
  1125.     Return .F.
  1126. Endif
  1127.  
  1128. *... The first '0' says use the default port, usually 21.
  1129. hftpsession = internetconnect (hopen, lchost,;
  1130.     0, lcuser, lcpassword, 1, 0, 0)   &&... 1 = ftp protocol
  1131. If hftpsession = 0
  1132.     * close access to Inet functions and exit
  1133.     = internetclosehandle (hopen)
  1134.     *!*       ? "ftp " + lcHost + " is not available"
  1135.     Return .F.
  1136. Else
  1137.     *!*       ? "Connected to " + lcHost
  1138. Endif
  1139. Return .T.
  1140. Return
  1141. *** End of ftpPut.PRG ***********************************************************
  1142. * open access to Inet functions
  1143. hopen = internetopen ("vfp", 1, 0, 0, 0)
  1144. If hopen = 0
  1145.     Return .F.
  1146. Endif
  1147. *... The first '0' says use the default port, usually 21.
  1148. hftpsession = internetconnect (hopen, lchost,;
  1149.     0, lcuser, lcpassword, 1, 0, 0)   &&... 1 = ftp protocol
  1150. If hftpsession = 0
  1151.     * close access to Inet functions and exit
  1152.     = internetclosehandle (hopen)
  1153.     *!*       ? "ftp " + lcHost + " is not available"
  1154.     Return .F.
  1155. Else
  1156.     *!*       ? "Connected to " + lcHost
  1157. Endif
  1158. Return .T.
  1159. Return
  1160. *** End of ftpPut.PRG ***********************************************************
  1161. *... The first '0' says use the default port, usually 21.
  1162. hftpsession = internetconnect (hopen, lchost,;
  1163.     0, lcuser, lcpassword, 1, 0, 0)   &&... 1 = ftp protocol
  1164. If hftpsession = 0
  1165.     * close access to Inet functions and exit
  1166.     = internetclosehandle (hopen)
  1167.     *!*       ? "ftp " + lcHost + " is not available"
  1168.     Return .F.
  1169. Else
  1170.     *!*       ? "Connected to " + lcHost
  1171. Endif
  1172. Return .T.
  1173. Return
  1174. *** End of ftpPut.PRG ***********************************************************
  1175. *** End of ftpPut.PRG *************************************************************
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement