FTP for all PB OS's
-
- Enthusiast
- Posts: 781
- Joined: Fri Apr 25, 2003 6:51 pm
- Location: NC, USA
- Contact:
Thank you for thisDare2 wrote:A framework for a client (uploaded using itself) is here:
http://www.tabturn.com/purebasic/PasvTfr.zip
The zip contains sources and an executable. The client uses winapi but the actual FTP is cross-platform based on what I learned here. The FTP part is quite different in some ways (I tried to write from ground up) but still based on and only possible because of the work here.

BTW: It doesn't work here. Maybe because my computer is behind a proxy. What do I have to do to get it going?
Terry, link is down, but I was able to find a recently downloaded file of it. still 0.7d ..
Anyways, line 44 (unable to allocate memory block size of 0 ...)
Block_Size is not given a value, what should go here? I actually put in 1024, though Im hoping there is no set defined value that needs to go here 
Bah, now that I am in a debugging mood .... turns out the variable assignment was in the wrong spot, fixed
there are a few other things im doing to this include before I post my version
basically some bug fixes, and replace missing variables, and no gadget dependencies! 

Code: Select all
Global *mem.l : *mem = AllocateMemory(Block_Size)

Bah, now that I am in a debugging mood .... turns out the variable assignment was in the wrong spot, fixed



-
- Enthusiast
- Posts: 781
- Joined: Fri Apr 25, 2003 6:51 pm
- Location: NC, USA
- Contact:
Link is back up now. 7d is the last that I have posted, although I have made a few more changes since then.Shannara wrote:Terry, link is down...
line 44 (unable to allocate memory block size of 0 ...)
Block_Size is not given a value, what should go here? I actually put in 1024, though Im hoping there is no set defined value that needs to go hereCode: Select all
Global *mem.l : *mem = AllocateMemory(Block_Size)
![]()
Block_Size can be varied. I have used several sizes to optimize the exchange with the FTP Server. Some servers allow the setting of the block size they use too. In that case, it is more efficient if the client matches. I have not attempted to determine this automatically yet.
Strange though, I have never experienced a problem with the line you mentioned up through PB Vs 3.93. But the Block_Size assignment needs to be relocated as you figured out.
Hi, sorry for such a long delay in answering, but was overseas. Got back a few hours ago.fsw wrote:BTW: It doesn't work here. Maybe because my computer is behind a proxy. What do I have to do to get it going?
Now for the answer - - - I don't have a clue. I'm basically a novice at this and what you got was my attempt to emulate the gurus here. The code doesn't even support PORT. But it does use PASV ...?
Anyway, will look at it in a few days (and find a proxy to hide behind) and see what I can see. Actually, first I'll try to find out what a proxy really is ...

Meantime, feel free to come up with a solution for me ..

@}--`--,-- A rose by any other name ..
Hi there 
I'm very interested in your FTP include, regrettably it won't work....
Actually it seems that your lib only allows passive mode file transferts (please tell me if I'm wrong), but I really need an active mode to get it to work on my FTP server...
I just get a "time out" error, a 0k file with the right name is created on the server but nothing else. It's really seems like both my server and my soft are waiting for something from the other and then... Time out!
I just need a ftp lib source honed to the essential (actually I just need creating a directory, changing directory and uploading a file)
Do you think that if the lib effectively only allows PASV file tranferts, I could easily implement an active way? do you have any clue?
thanks in advance.
popstatic
(great work;) )

I'm very interested in your FTP include, regrettably it won't work....
Actually it seems that your lib only allows passive mode file transferts (please tell me if I'm wrong), but I really need an active mode to get it to work on my FTP server...
I just get a "time out" error, a 0k file with the right name is created on the server but nothing else. It's really seems like both my server and my soft are waiting for something from the other and then... Time out!
I just need a ftp lib source honed to the essential (actually I just need creating a directory, changing directory and uploading a file)
Do you think that if the lib effectively only allows PASV file tranferts, I could easily implement an active way? do you have any clue?
thanks in advance.
popstatic
(great work;) )
You're pretty when I'm drunk, and I'm pretty fuckin' drunk.
-
- Addict
- Posts: 1648
- Joined: Mon Sep 20, 2004 3:52 pm
- Contact:
-
- Enthusiast
- Posts: 115
- Joined: Wed Jun 02, 2004 10:17 pm
- Location: New Caledonia (South Pacific)
- Contact:
If anybody is still interrested by this library, you can find a new version for PB4, compatible with the Unicode option on.
It is included in my DropUpLoad Package at:
http://www.rankspirit.com/downloads/dropupload.zip
This version has been tested with hundreds of FTP Servers through the world and I thinck that I can say that it is absolutelly reliable (even if not really eleguantly coded
)
It supports Active and Passive modes.
It is included in my DropUpLoad Package at:
http://www.rankspirit.com/downloads/dropupload.zip
This version has been tested with hundreds of FTP Servers through the world and I thinck that I can say that it is absolutelly reliable (even if not really eleguantly coded

It supports Active and Passive modes.
Don't try - DO it !
-
- Enthusiast
- Posts: 115
- Joined: Wed Jun 02, 2004 10:17 pm
- Location: New Caledonia (South Pacific)
- Contact:
All you need is PB4.
Here is a question by pm from Nico:
Hello Nico,
You need the FTP_ChangeDir command.
here is an example:
Here is a question by pm from Nico:
and the answer:Hi
I have one question to your lib. How i can set a folder for the FTP at the FTP-Server config?
THX Nico
Hello Nico,
You need the FTP_ChangeDir command.
here is an example:
Code: Select all
#LFCR = Chr(13) + Chr(10)
#Refresh = 0
#BInter = 0
XIncludeFile ("FTP_Library_Include_Z5.pb")
; ___________________________________________________________
; Parameters - Paramétrage
; ___________________________________________________________
Server.ServerStruct\Name = "Nom du serveur" ; Name is not important - Peu importe le nom
Server\Adress = "ftp.monsite.com/html/" ; ai.e. ftp.monsite.com/html/ - sous la forme ftp.monsite.com/html/, par exemple
Server\Login = "monlogin"
Server\Password = "monpassword"
Server\Port = 21 ; most of the servers use port#21 - la plupart des serveurs utilisent le port 21
Server\Active = 0 ; most of the servers work better in passive mode - la plupart des serveurs fonctionnent mieux en mode passif
Server\TimeOut = 10000 ; 10 seconds timout - time out de 10 secondes (10000 millisecondes)
;
; --------------------------------------------------------------------------------------------------------
; Split the path and the server name
; On sépare le nom du serveur du chemin d'accés
pos = FindString(Server\Adress,"/",0)
If pos = 0 : pos = Len(Server\Adress)+1 : EndIf
path$ = Right(Server\Adress,Len(Server\Adress)-pos)
If path$ = "/" : path$ = "" : EndIf
If path$ And Right(path$,1)<>"/" : path$ + "/" : EndIf ; Now, path$ contains the path - path$ contient maintenant le chemin d'accés
Server\Adress = Left(Server\Adress,pos-1)
;
; --------------------------------------------------------------------------------------------------------
FTP_Init()
FTP_Connect(Server,0) ; open the connection - ouverture de la connection
If PortID ; PortID is a global variable which contains the number of the internal connection port - PortID est une variable globale contenant le n° du port interne affecté à la connection
If FTP_Login(PortID, Server, 0) = #FTP_OK ; send login and password - envoi du login et du mot de passe
While path$ ; we'll use the ChangeDir command to access to the path - On va utiliser la commande "ChangeDir" jusqu'à atteindre le répertoire indiqué par le chemin d'accés.
pos = FindString(path$,"/",0)
If pos = 0 : pos = Len(path$)+1 : EndIf
dirT$ = Left(path$,pos-1)
path$ = Right(path$,Len(path$)-pos)
ResultCD = FTP_ChangeDir(PortID, Server, dirT$, Log_Gadget)
If ResultCD <> #FTP_OK And ResultCD <> 550
ResultFTPDIR$ = "!!Error while opening the directory!! "+dirT$+" ("+Str(ResultCD)+")"
Debug ResultFTPDIR$
ElseIf ResultCD = 550
Answ = MessageRequester("FTP",dirT$+" does'nt exist. Do you want to create it?",#PB_MessageRequester_YesNo)
If Answ = 6
If FTP_MakeDir(PortID, Server, dirT$, 0) = #FTP_OK
If FTP_ChangeDir(PortID, Server, dirT$, 0) <> #FTP_OK
ResultFTPDIR$ = "!!Error while opening the directory!! "+dirT$
Debug ResultFTPDIR$
EndIf
Else
ResultFTPDIR$ = "!!Error while creating the directory!! "+dirT$
EndIf
EndIf
EndIf
Wend
;
;
; If all is OK, we are now inside the good server repertory
; Si tout s'est bien passé, nous sommes à présent connecté et positionné dans le bon dossier du serveur
;
; We can do (as an example):
; On peut faire, par exemple :
;
;File_to_upload$ = "c:\\myfile.txt" ; <----------- put here the name of the file to upload
;ProgBarGadgetID = My_Gadget ; <----------- put here the # of the progression bar gadgetn
;FTP_Store(PortID, Server, File_to_upload$, ProgBarGadgetID.l, 0)
;Fichier_a_uploader$ = "c:\\monfichier.txt" ; <----------- entre ici le nom du fichier que tu veux uploader
;ProgBarGadgetID = Mon_Gadget ; <----------- entre ici le N° du gadget qui fait barre de progression
;FTP_Store(PortID, Server, Fichier_a_uploader$, ProgBarGadgetID.l, 0)
; Or simply - Ou simplement
Result = FTP_List(PortID, Server,"", DList.DirList, 0) ; to get the repertory content - pour obtenir le contenu du répertoire
Debug DList\DirectoryList
;
FTP_Logout(0)
PortID = 0
EndIf
EndIf
Don't try - DO it !