Posted: Sun Jul 17, 2005 12:59 pm
Congratulations, Dare2. That's a big stuff!
http://www.purebasic.com
https://www.purebasic.fr/english/
Oops, sorry. Didn't mean to overlook you or Num3 who started it all.DarkDragon wrote:And mine? You have forgotten me!TerryHough wrote:First, which FTP_Include are you using? Mine, Zapman's, or a modified
one?
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.
Code: Select all
Global *mem.l : *mem = AllocateMemory(Block_Size)
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)
![]()
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?
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
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