Step One - Connecting to your server
Logically before you can call any FTP function you will first need to connect to an FTP server. You need to define a couple of strings in order to fulfill the requirements for the connection function. Execute this code before attempting to connect to an FTP server.
`Initial settings call before you access the Connect() sub
Username$ = "username" `Replace with your username
Password$ = "password" `Replace with your password
Server$ = "server.com" `Replace with the server you would like to connect to
Now to actually connect to your server create and call the following Sub.
Connect():
`Connect to the desired FTP server using the specified username and password
ftp connect Server$, Username$, Password$
`Check for errors
If Get FTP Failure() = 0
`Connected Successfully
else
`There was an error
EndIf
Return
If you do not know how to call the above function simply use this code: gosub Connect().
Step Two - Getting Files Off the Server
To download a file off the server after you have successfully connected use create a sub called GetFile(). However before you call the GetFile() sub define the following strings as follows:
RemoteFile$ = "filename" `Replace with the name of the file you wish to download
LocalFile$ = "filenameandpath" `Replace with path and filename of the new file
Once you've defined the above you are now free to use this code to make your GetFile() sub.
GetFile():
FTP Get File RemoteFile$, LocalFile$
IF Get FTP Failure() = 0
`The File Was Downloaded Successfully - Place Desired Code Here
else
`There was an error while downloading the file - Place Desired Code Here
EndIf
Return
Step Three - Putting Files Onto the Server
LocalPutFile$ = "filenameandpath"
RemotePutFile$ = "filename
PutFile():
FTP Put File LocalPutFile$, RemotePutFile$
IF Get FTP Failure() = 0
`The File Was Successfully Uploaded - Insert Desired Code Here
else
`There was an error while uploading the file - Insert Desired Code Here
EndIf
Return
Step Four Deleting File on the Server
FileToDel$ = "filename"
DeleteFile():
FTP Delete File FileToDel$
IF Get FTP Failure() = 0
`The File Was Properly Deleted - Place Code Here
else
`There was an error while attempting to delete the file - Place Code Here
EndIf
Return
End
Just a quick note, if you want to change directories in you FTP server simply call this function, "Set FTP Dir()",supplying the directory name as a parameter.
When you wish to disconnect from the FTP server after you have performed your desired functions call, "FTP Disconnect".
This concludes this tutorial on DarkBasic Professional: FTP Functions.
Published by James Cloud
I like to program and do basically anything that has to do with technology and computers. View profile
- Product Review: Crest Pro-Health Mouth WashI love mouth wash, but I am not a big fan of how much it usually burns. I find it very hard to keep that much mouth wash in my mouth for thirty seconds. So, when I discovered Crest Pro-Health, I was very happy.
- There is No Such Thing as Pro-Life or Pro-ChoiceI find it hard to take Pro-Life and Pro-Choice activists serious..
A Personal Account of What Pro-Life Really MeansEveryone wants to talk about when life begins. But how about talking about what life is? If you chose to be pro life, should you pick and chose definitions based on religious or...- Presidential Hopeful Mitt Romney and His Pro-Life WaffleMitt Romney is in the race to be the Republican Party's candidate for the U. S. Presidency. His flip flop on Pro Life has opened the door for confrontation with other Party candidates.
How to Do Lens and Perspective Correction in Paint Shop ProSometimes pictures come out with lens and perspective distortion, and distracting background elements. If your item is square
or rectangular, such as a painting or print, t...
- Warren Moon, First Afro-American Quarterback Inducted into the Pro Football Hall o...
- Gaming Accessory Review: Intec Pro Gamer's Kit
- Photoshop Tutorial: Learning How to Use and Load Brushes in Photoshop
- Photoshop Tutorial: Adding Digital Rain to Your Images
- Photoshop Tutorial: Color Correcting and Tone Enhancing Photographs
- Beginner's Photoshop Tutorial: Learning to Create Your Own Brushes
- "You Can't Be Catholic and Be Pro..." A Bumper Sticker Enlightens Me on Religion



