Page 1 of 1

Hmmm... can I upload via FTP with nothing but PB?

Posted: Mon Mar 29, 2004 2:19 am
by deadmoap
I really need to be able to upload via FTP... but I don't know how to do it in C++ and I don't know any DLLs either.

Posted: Mon Mar 29, 2004 7:41 am
by benny
Hi,

if you are using Windows, you could use the WinApi-FTP-Functions. There are several examples here in the forum and on http://www.purearea.net, like the following one :

Code: Select all

; www.purearea.net (Sourcecode collection by cnesm)
; Author:
; Date: 22. November 2003

#INTERNET_SERVICE_FTP=1
#INTERNET_OPEN_TYPE_DIRECT=1
#FTP_PORT=21
#FTP_TRANSFER_ASCII=1
#FTP_TRANSFER_BINARY=2
Proxy.s=""
ProxyBypass.s=""
ServerName.s="namedesftpservers"
UserName.s="testuser"
Password.s="testepass"
localfile.s="iptext.txt"
remotefile.s="iptext.txt"

hInternet=InternetOpen_("FTP",#INTERNET_OPEN_TYPE_DIRECT,Proxy,ProxyBypass,0)
If hInternet
  hConnect=InternetConnect_(hInternet,ServerName,#FTP_PORT,UserName,Password,#INTERNET_SERVICE_FTP,0,0)
  If hConnect
    If FtpPutFile_(hConnect,localfile,remotefile,#FTP_TRANSFER_ASCII,0)
      MessageRequester("","File has been sent",0)
    Else
      MessageRequester("Error", "Failure while sending file...",0)
    EndIf
  Else
    MessageRequester("Error", "Couldn't get a connection to the server!",0)
  EndIf
  InternetCloseHandle_(hInternet)
Else
  MessageRequester("Error", "Internet isn't reachable.",0)
EndIf

Posted: Mon Mar 29, 2004 8:54 am
by thefool
You should be able to make ftp upload with nothing but pb. Try to telnet an ftp server, understand the commands and then study the network functions in PB.

Posted: Mon Mar 29, 2004 10:36 am
by benny
@deadmop:

If you do not know what thefool means ... try this as a start :
(1) open a dos-box / console-window
(2) type "telnet ftp.yourserver.com 21"
(3) after you are connected type "USER youraccount"+RETURN
(4) then type "PASS yourpassword"+RETURN
(5) type "HELP" for available commands

Posted: Tue Mar 30, 2004 12:48 am
by dagcrack
Read all the ftp commands, and then learn using TCP commands at PB, is hell easy. I even made an ftp client on Blitz3D using a few TCP commands.

Posted: Tue Mar 30, 2004 10:27 am
by Johan_Haegg

Posted: Tue Mar 30, 2004 11:20 am
by GedB
deadmoap,

Consider using REBOL. The core is free.

http://www.rebol.com/docs/core23/rebolcore-13.html