Jump to content

FTP Upload .txt files


Fichte
 Share

Recommended Posts

Found much but dont know how to configure.

I found this:

It everytime returns 0 0 as message.

$server = "*like http://name.servername.de*";can take ip or hostname: home.arcor.de(german host)

$username = "*name*";i know this

$pass = "*passpord*"; and this either laugh.gif

$passive = 1; 0 = active, 1 = passive (just found in this forum graduated.gif )

$Open = _FTPOpen("MyFTP Control")

$Conn = _FTPConnect($Open, $server, $username, $pass,$passive)

$Ftpp = _FtpPutFile($Conn,@ScriptDir&"\user.txt","/klick/user.txt")

MsgBox(0,"",$Conn&" "&$Ftpp);return 0 0 => failure

$Ftpc = _FTPClose($Open)

;to change dictonary in this way _FtpSetCurrentDir($Conn, "/upload_dir/") doesn't work either cause a problem occours when i want to connect to "my" server

;===============================================================================

;

; Function Name: _FTPOpen()

; Description: Opens an FTP session.

; Parameter(s): $s_Agent - Random name. ( like "myftp" )

; $l_AccessType - I dont got a clue what this does.

; $s_ProxyName - ProxyName.

; $s_ProxyBypass - ProxyByPasses's.

; $l_Flags - Special flags.

; Requirement(s): DllCall, wininet.dll

; Return Value(s): On Success - Returns an indentifier.

; On Failure - 0 and sets @ERROR

; Author(s): Wouter van Kesteren.

;

;===============================================================================

Func _FTPOpen($s_Agent, $l_AccessType = 1, $s_ProxyName = '', $s_ProxyBypass = '', $l_Flags = 0)

Local $ai_InternetOpen = DllCall('wininet.dll', 'long', 'InternetOpen', 'str', $s_Agent, 'long', $l_AccessType, 'str', $s_ProxyName, 'str', $s_ProxyBypass, 'long', $l_Flags)

If @error OR $ai_InternetOpen[0] = 0 Then

SetError(-1)

Return 0

EndIf

Return $ai_InternetOpen[0]

EndFunc ;==> _FTPOpen()

;===============================================================================

;

; Function Name: _FTPConnect()

; Description: Connects to an FTP server.

; Parameter(s): $l_InternetSession - The Long from _FTPOpen()

; $s_ServerName - Server name/ip.

; $s_Username - Username.

; $s_Password - Password.

; $i_ServerPort - Server port ( 0 is default (21) )

; $l_Service - I dont got a clue what this does.

; $l_Flags - Special flags.

; $l_Context - I dont got a clue what this does.

; Requirement(s): DllCall, wininet.dll

; Return Value(s): On Success - Returns an indentifier.

; On Failure - 0 and sets @ERROR

; Author(s): Wouter van Kesteren

;

;===============================================================================

Func _FTPConnect($l_InternetSession, $s_ServerName, $s_Username, $s_Password, $i_ServerPort = 0, $l_Service = 1, $l_Flags = 0, $l_Context = 0)

Local $ai_InternetConnect = DllCall('wininet.dll', 'long', 'InternetConnect', 'long', $l_InternetSession, 'str', $s_ServerName, 'int', $i_ServerPort, 'str', $s_Username, 'str', $s_Password, 'long', $l_Service, 'long', $l_Flags, 'long', $l_Context)

If @error OR $ai_InternetConnect[0] = 0 Then

SetError(-1)

Return 0

EndIf

Return $ai_InternetConnect[0]

EndFunc ;==> _FTPConnect()

;===============================================================================

;

; Function Name: _FTPPutFile()

; Description: Puts an file on an FTP server.

; Parameter(s): $l_FTPSession - The Long from _FTPConnect()

; $s_LocalFile - The local file.

; $s_RemoteFile - The remote Location for the file.

; $l_Flags - Special flags.

; $l_Context - I dont got a clue what this does.

; Requirement(s): DllCall, wininet.dll

; Return Value(s): On Success - 1

; On Failure - 0

; Author(s): Wouter van Kesteren

;

;===============================================================================

Func _FTPPutFile($l_FTPSession, $s_LocalFile, $s_RemoteFile, $l_Flags = 0, $l_Context = 0)

Local $ai_FTPPutFile = DllCall('wininet.dll', 'int', 'FtpPutFile', 'long', $l_FTPSession, 'str', $s_LocalFile, 'str', $s_RemoteFile, 'long', $l_Flags, 'long', $l_Context)

If @error OR $ai_FTPPutFile[0] = 0 Then

SetError(-1)

Return 0

EndIf

Return $ai_FTPPutFile[0]

EndFunc ;==> _FTPPutFile()

;===============================================================================

;

; Function Name: _FTPDelFile()

; Description: Delete an file from an FTP server.

; Parameter(s): $l_FTPSession - The Long from _FTPConnect()

; $s_RemoteFile - The remote Location for the file.

; Requirement(s): DllCall, wininet.dll

; Return Value(s): On Success - 1

; On Failure - 0

; Author(s): Wouter van Kesteren

;

;===============================================================================

Func _FTPDelFile($l_FTPSession, $s_RemoteFile)

Local $ai_FTPPutFile = DllCall('wininet.dll', 'int', 'FtpDeleteFile', 'long', $l_FTPSession, 'str', $s_RemoteFile)

If @error OR $ai_FTPPutFile[0] = 0 Then

SetError(-1)

Return 0

EndIf

Return $ai_FTPPutFile[0]

EndFunc ;==> _FTPDelFile()

;===============================================================================

;

; Function Name: _FTPRenameFile()

; Description: Renames an file on an FTP server.

; Parameter(s): $l_FTPSession - The Long from _FTPConnect()

; $s_Existing - The old file name.

; $s_New - The new file name.

; Requirement(s): DllCall, wininet.dll

; Return Value(s): On Success - 1

; On Failure - 0

; Author(s): Wouter van Kesteren

;

;===============================================================================

Func _FTPRenameFile($l_FTPSession, $s_Existing, $s_New)

Local $ai_FTPRenameFile = DllCall('wininet.dll', 'int', 'FtpRenameFile', 'long', $l_FTPSession, 'str', $s_Existing, 'str', $s_New)

If @error OR $ai_FTPRenameFile[0] = 0 Then

SetError(-1)

Return 0

EndIf

Return $ai_FTPRenameFile[0]

EndFunc ;==> _FTPRenameFile()

;===============================================================================

;

; Function Name: _FTPMakeDir()

; Description: Makes an Directory on an FTP server.

; Parameter(s): $l_FTPSession - The Long from _FTPConnect()

; $s_Remote - The file name to be deleted.

; Requirement(s): DllCall, wininet.dll

; Return Value(s): On Success - 1

; On Failure - 0

; Author(s): Wouter van Kesteren

;

;===============================================================================

Func _FTPMakeDir($l_FTPSession, $s_Remote)

Local $ai_FTPMakeDir = DllCall('wininet.dll', 'int', 'FtpCreateDirectory', 'long', $l_FTPSession, 'str', $s_Remote)

If @error OR $ai_FTPMakeDir[0] = 0 Then

SetError(-1)

Return 0

EndIf

Return $ai_FTPMakeDir[0]

EndFunc ;==> _FTPMakeDir()

;===============================================================================

;

; Function Name: _FTPDelDir()

; Description: Delete's an Directory on an FTP server.

; Parameter(s): $l_FTPSession - The Long from _FTPConnect()

; $s_Remote - The Directory to be deleted.

; Requirement(s): DllCall, wininet.dll

; Return Value(s): On Success - 1

; On Failure - 0

; Author(s): Wouter van Kesteren

;

;===============================================================================

Func _FTPDelDir($l_FTPSession, $s_Remote)

Local $ai_FTPDelDir = DllCall('wininet.dll', 'int', 'FtpRemoveDirectory', 'long', $l_FTPSession, 'str', $s_Remote)

If @error OR $ai_FTPDelDir[0] = 0 Then

SetError(-1)

Return 0

EndIf

Return $ai_FTPDelDir[0]

EndFunc ;==> _FTPDelDir()

;===============================================================================

;

; Function Name: _FTPClose()

; Description: Closes the _FTPOpen session.

; Parameter(s): $l_InternetSession - The Long from _FTPOpen()

; Requirement(s): DllCall, wininet.dll

; Return Value(s): On Success - 1

; On Failure - 0

; Author(s): Wouter van Kesteren

;

;===============================================================================

Func _FTPClose($l_InternetSession)

Local $ai_InternetCloseHandle = DllCall('wininet.dll', 'int', 'InternetCloseHandle', 'long', $l_InternetSession)

If @error OR $ai_InternetCloseHandle[0] = 0 Then

SetError(-1)

Return 0

EndIf

Return $ai_InternetCloseHandle[0]

EndFunc ;==> _FTPClose()

Link to comment
Share on other sites

Found much but dont know how to configure.

I found this:

It everytime returns 0 0 as message.

$server = "*like http://name.servername.de*";can take ip or hostname: home.arcor.de(german host)

$username = "*name*";i know this

$pass = "*passpord*"; and this either laugh.gif

$passive = 1; 0 = active, 1 = passive (just found in this forum graduated.gif )

$Open = _FTPOpen("MyFTP Control")

$Conn = _FTPConnect($Open, $server, $username, $pass,$passive)

$Ftpp = _FtpPutFile($Conn,@ScriptDir&"\user.txt","/klick/user.txt")

MsgBox(0,"",$Conn&" "&$Ftpp);return 0 0 => failure

If you are going to post that much code, use {codebox} or {autoit} tags (with square brackets vice curly braces).

You don't have to include the contents of FTP.au3, jut put it at the top with "#include <FTP.au3>" unless you have modified the functions.

Your $server should not be a full URL with protocol specification. Because you are using _FTPOpen(), the protocol will, of course, be FTP. Just use $server = "name.servername.de".

Note the conversations recently in the topic for FTP.au3 where it points out the need to open the DLL before using the functions with "$dllhandle = DLLOpen('wininet.dll')".

:D

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

o.O

Maybe i am too stupid maybe its couse i'm working with AutoItScript just for 1 month don't know.

it still not works.

plz help.

my Server: http://siehstemal.kilu.de

my Name : siehstemal

my Pw: 1234qwer

the programm is in same folder like the file

filename: user.txt

i want to upload it into the folder on server: klick

i think the path should be: http://siehstemal.kilu.de/klick/user.txt

it isnt working with that:

CODE
#include <FTP.au3>

$server = "siehstemal.kilu.de"

$username = "siehstenmal"

$pass = "1234qwer"

$Open = _FTPOpen('MyFTP Control')

$Conn = _FTPConnect($Open, $server, $username, $pass)

$Ftpp = _FtpPutFile($Conn, '/user.txt', '/klick/user.txt')

$Ftpc = _FTPClose($Open)

MsgBox(0,"",$Conn&" "&$Ftpp)

plz tell me what i make wrong cuz i wanna learn this interesting part of AutoItScript

Want to create a "Browsergame".

Thx for Any Help-Reply

Greetings Fichte

PS: plz dont do any crap with these datas. is just my last hope to learn this part.

Edited by Fichte
Link to comment
Share on other sites

o.O

Maybe i am too stupid maybe its couse i'm working with AutoItScript just for 1 month don't know.

it still not works.

plz help.

my Server: http://siehstemal.kilu.de

my Name : siehstemal

my Pw: 1234qwer

the programm is in same folder like the file

filename: user.txt

i want to upload it into the folder on server: klick

i think the path should be: http://siehstemal.kilu.de/klick/user.txt

it isnt working with that:

CODE
#include <FTP.au3>

$server = "siehstemal.kilu.de"

$username = "siehstemal"

$pass = "1234qwer"

$Open = _FTPOpen('MyFTP Control')

$Conn = _FTPConnect($Open, $server, $username, $pass)

$Ftpp = _FtpPutFile($Conn, '/user.txt', '/klick/user.txt')

$Ftpc = _FTPClose($Open)

MsgBox(0,"",$Conn&" "&$Ftpp)

plz tell me what i make wrong cuz i wanna learn this interesting part of AutoItScript

Want to create a "Browsergame".

Thx for Any Help-Reply

Greetings Fichte

PS: plz dont do any crap with these datas. is just my last hope to learn this part.

Link to comment
Share on other sites

Errm... I wouldn't be posting account info like that. :D

Smarter play would be to create a limited test account and post that you will give it to anyone that wishes to PM you for it to help.

:P

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

does the /klick directory actually exist on the server? If not then you probably need to use

_FTPMakeDir()

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...