Jump to content
Juliano

Carregar arquivo em um FTP

Recommended Posts

Caros, boa tarde!

 

Preciso de um codigo no autoit, que carregue um arquivo txt em um FTP.

 

Alguém pode me ajudar?

 

Nome do Arquivo: Prioridade.txt

 

Abs.

Share this post


Link to post
Share on other sites

Olá.

 

Além dos excelentes artigos do AutoItCoder, veja esta biblioteca de FTP em AutoIt.

 

Segue exemplo:

#include <FTP.au3>
#include <Array.au3> ; only used for this test file to dispay the return value of the _FTPFileFind* functions

$server = 'FTP Server Name'
$username = 'username'
$pass = 'password'

;Please Note Trailing and Leading slashes (back or forward) for directoryies local and remote for all commands, as they are critical

;$Hand will be a handle in the form of an array containing multiple handles and information, and is the only handle referenced
$Hand = _FTPOpen('Doesnt Matter')

_FTPConnect($Hand, $server, $username, $pass)
if @error then msgbox(0,"Error","Connect")

_FtpPutFile($Hand, 'C:\WINDOWS\Notepad.exe', '/')  ;Upload to top level directory with same file name as local
if @error then msgbox(0,"Error","PutFile 1")

_FtpPutFile($Hand, 'C:\WINDOWS\Notepad.exe', '/Notepad2.exe')  ;Upload to top level directory with different file name
if @error then msgbox(0,"Error","PutFile 2")

_FTPMakeDir($Hand, 'ExampleFolder')  ;Make directory in current directory
if @error then msgbox(0,"Error","MakeDir")

_FTPMakeDir($Hand, 'ExampleFolder/ExampleFolder2')  ;Make directory in 'ExampleFolder'
if @error then msgbox(0,"Error","MakeDir")

_FtpPutFile($Hand, 'C:\WINDOWS\Notepad.exe', '/ExampleFolder/Example3.exe')  ;Upload to sub directory with different file name
if @error then msgbox(0,"Error","PutFile 3")

_FTPGetFile($Hand, '/ExampleFolder/Example3.exe', @ScriptDir & '\Example3.exe')
if @error then msgbox(0,"Error","Get File")

$FIRSTFILEINFO= _FTPFileFindFirst($Hand,"*")
if @error then
    msgbox(0,"Error","_FileFindFirst")
Else
    _ArrayDisplay($FIRSTFILEINFO)
EndIf

$SECONDFILEINFO= _FTPFileFindNext($Hand)
if @error then
    msgbox(0,"Error","_FTPFileFindNext")
Else
    _ArrayDisplay($SECONDFILEINFO)
EndIf

$THIRDFILEINFO= _FTPFileFindNext($Hand)
if @error then
    msgbox(0,"Error","_FTPFileFindNext")
Else
    _ArrayDisplay($THIRDFILEINFO)
EndIf

_FTPFileFindClose($Hand);Only one _FTPFileFind() can go on at a time so it must be closed before using _FTPGetFolderContents()

_FTPGetFolderContents($Hand,"/ExampleFolder/",@DesktopDir&"\ftp udf test\",1)

_FTPClose($Hand);Close ftp session

FTP.au3

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now


×