FTP for all PB OS's

Share your advanced PureBasic knowledge/code with the community.
Num3
PureBasic Expert
PureBasic Expert
Posts: 2812
Joined: Fri Apr 25, 2003 4:51 pm
Location: Portugal, Lisbon
Contact:

FTP for all PB OS's

Post by Num3 »

Tired of window API?
Wanna have FTP support for your code?

Here it is! Just for 0.99cents !!! :mrgreen:

*EDIT*

Here's the windows library! (33kb)>>> HERE <<<
The Library includes source code and example project :P

*EDIT*

Code: Select all

; Code by Num3 - 2004

server_reply.s=Space(10240)
#ftp_port=21
#LFCR=Chr(13)+Chr(10)

#FTP_OK = 1
#FTP_ERROR = 0
#FTP_TimeOut = -1

Global FTP_Last_Message.s, ftp_data.l

Procedure Int_FTP_PASV(Ftp)
  
  Delay(100)
  SendNetworkString(Ftp,"PASV"+#LFCR)
  
  time.l=Date()
  
  Repeat
    event=NetworkClientEvent(Ftp)
    
    If event=0
      
      now=Date() 
      If now-time > 20 
        FTP_Last_Message="Time out"
        ProcedureReturn #FTP_TimeOut
      EndIf
      
    ElseIf event=2
      
      In.s=Space(10240)
      result=ReceiveNetworkData(Ftp,@In,Len(In))
      In=Trim(In)
      FTP_Last_Message=In
      
      ;{ -- Analise data --
      
      ; -- Error Parsing
      If FindString(In,"530",1)
        ProcedureReturn #FTP_ERROR
      EndIf
      
      ; -- OK Parsing
      
      ;{ -- Retrieve Server IP and Data Port
      If FindString(In,"227",1)
        Argument$=Trim(In)
        startpos=FindString(Argument$, "(", 1)
        Position = FindString(Argument$, ",", 1)
        server_ip.s = Mid(Argument$, startpos+1, Position-1-startpos)+"."
        NewPosition = FindString(Argument$, ",", Position+1)
        server_ip= server_ip+Mid(Argument$, Position+1, NewPosition-Position-1)+"."
        Position = FindString(Argument$, ",", NewPosition+1)
        server_ip= server_ip+Mid(Argument$, NewPosition+1, Position-NewPosition-1)+"."
        NewPosition = FindString(Argument$, ",", Position+1)
        server_ip= server_ip+Mid(Argument$, Position+1, NewPosition-Position-1)
        server_ip = Trim(server_ip)
        ; Get the port..
        ;
        Position = FindString(Argument$, ",", NewPosition+1)
        ClientPort = Val(Mid(Argument$, NewPosition+1, Position-NewPosition-1)) << 8+Val(Right(Argument$, Len(Argument$)-Position))
        ;}
        
        ftp_data= OpenNetworkConnection(server_ip,ClientPort)
        
        If ftp_data
          ProcedureReturn #FTP_OK
        EndIf
        
      EndIf
      
      ;}
      
    EndIf
    
    Delay(50)
    
  Until quit=1
  
  quit=0
  
  ProcedureReturn #FTP_OK 
  
EndProcedure


Procedure Int_FTP_PASV_CLOSE()
  CloseNetworkConnection(ftp_data)
  ftp_data=0
EndProcedure

Procedure.s FTP_Last_Message()
  ProcedureReturn FTP_Last_Message
EndProcedure

Procedure FTP_Init()
  If InitNetwork() 
    ProcedureReturn 1
  Else
    FTP_Last_Message="Unable to start TCP/IP stack..."
    ProcedureReturn 0
  EndIf
EndProcedure

Procedure FTP_Connect(Server.s,Port.l) ; // Returns FTPconnection
  thread.l=OpenNetworkConnection(Server,Port)
  If thread
    ProcedureReturn thread
  Else
    FTP_Last_Message="Unable to connect to specified server..."
    ProcedureReturn 0
  EndIf
EndProcedure

Procedure FTP_Login(Ftp.l,UserName.s,Password.s)
  
  If Ftp=0
    ProcedureReturn #FTP_ERROR
  EndIf
  
    Delay(100)
  SendNetworkString(Ftp,"USER "+UserName+#LFCR)
  
  time.l=Date()
  
  Repeat
    event=NetworkClientEvent(Ftp)
    
    If event=0
      
      now=Date()
      If now-time > 20 
        ProcedureReturn #FTP_TimeOut
      EndIf
      
    ElseIf event=2
      
      In.s=Space(10240)
      result=ReceiveNetworkData(Ftp,@In,Len(In))
      In=Trim(In)
      FTP_Last_Message=In
      
      ;{ -- Analise data --
      
      ; -- Error Parsing
      If FindString(In,"530",1)
        ProcedureReturn #FTP_ERROR
      EndIf
      
      ; -- OK Parsing
      
      If FindString(In,"331",1)
        time.l=Date()
        SendNetworkString(Ftp,"PASS "+Password+#LFCR)
      EndIf
      
      If FindString(In,"230",1)
        time.l=Date()
        SendNetworkString(Ftp,"TYPE A"+#LFCR)
        ProcedureReturn #FTP_OK
      EndIf
      
      ;}
      
    EndIf
    
    Delay(50)
    
  Until quit=1
  
  quit=0
  
  ProcedureReturn #FTP_OK 
  
EndProcedure

Procedure FTP_LogOut(Ftp.l)
  
  If Ftp=0
    ProcedureReturn #FTP_ERROR
  EndIf
  
    Delay(100)
  SendNetworkString(Ftp,"QUIT"+#LFCR)
  
  time.l=Date()
  
  Repeat
    event=NetworkClientEvent(Ftp)
    
    If event=0
      
      now=Date() 
      If now-time > 20 
        FTP_Last_Message="Time out"
        ProcedureReturn #FTP_TimeOut
      EndIf
      
    ElseIf event=2
      
      In.s=Space(10240)
      result=ReceiveNetworkData(Ftp,@In,Len(In))
      In=Trim(In)
      FTP_Last_Message=In
      
      ;{ -- Analise data --
      
      ; -- Error Parsing
      If FindString(In,"530",1)
        ProcedureReturn #FTP_ERROR
      EndIf
      
      ; -- OK Parsing
      
      If FindString(In,"221",1)
        time.l=Date()
        ProcedureReturn #FTP_OK
      EndIf
      
      ;}
      
    EndIf
    
    Delay(50)
    
  Until quit=1
  
  quit=0
  
  ProcedureReturn #FTP_OK 
EndProcedure

Procedure FTP_Close(Ftp.l)
  If Ftp=0
    ProcedureReturn #FTP_ERROR
  EndIf
  
  If CloseNetworkConnection(Ftp)
    ProcedureReturn #FTP_OK
  Else
    FTP_Last_Message="Unable to close specified ftp connection"
    ProcedureReturn #FTP_ERROR
  EndIf
EndProcedure

Procedure FTP_List(Ftp.l)
  
  If Ftp=0
    ProcedureReturn #FTP_ERROR
  EndIf
  
  If ftp_data=0
    If Int_FTP_PASV(Ftp)=0
      ProcedureReturn #FTP_ERROR
    EndIf
  EndIf
  
    Delay(100)
  SendNetworkString(Ftp,"LIST"+#LFCR)
  
  time.l=Date()
  
  Repeat
    event=NetworkClientEvent(Ftp)
    
    If ftp_data
      ftp_data_event=NetworkClientEvent(ftp_data)
    EndIf
    
    If ftp_data_event=2
      In.s=Space(48000)
      result=ReceiveNetworkData(ftp_data,@In,Len(In))
      In=Trim(In)
      FTP_Last_Message=In
      Int_FTP_PASV_CLOSE()
      ProcedureReturn #FTP_OK
    EndIf
    
    If event=0
      
      now=Date() 
      If now-time > 20 
        FTP_Last_Message="Time out"
        ProcedureReturn #FTP_TimeOut
      EndIf
      
    ElseIf event=2
      
      In.s=Space(10240)
      result=ReceiveNetworkData(Ftp,@In,Len(In))
      In=Trim(In)
      FTP_Last_Message=In
      
      ;{ -- Analise data --
      
      ; -- Error Parsing
      If FindString(In,"530",1)
        ProcedureReturn #FTP_ERROR
      EndIf
      
      ; -- OK Parsing
      time.l=Date()
      
      
      ;}
      
    EndIf
    
    Delay(50)
    
  Until quit=1
  
  quit=0
  
  ProcedureReturn #FTP_OK 
EndProcedure

Procedure FTP_Retrieve(Ftp.l,filename.s,Destination.s)
  
  If Ftp=0
    ProcedureReturn #FTP_ERROR
  EndIf
  
  If ftp_data=0
    If Int_FTP_PASV(Ftp)=0
      ProcedureReturn #FTP_ERROR
    EndIf
  EndIf
  
  mem=AllocateMemory(64000)
  
  If CreateFile(0,Destination+filename)=0 And mem
    FTP_Last_Message="Unable to create file"
    CloseNetworkConnection(ftp_data)
    ProcedureReturn #FTP_ERROR
  EndIf
  
    Delay(100)
  SendNetworkString(Ftp,"RETR "+filename+#LFCR)
  
  time.l=Date()
  
  Repeat
    event=NetworkClientEvent(Ftp)
    
    If ftp_data
      ftp_data_event=NetworkClientEvent(ftp_data)
    EndIf
    
    If ftp_data_event=2
      result=ReceiveNetworkData(ftp_data,mem,64000)
      If result>0
        WriteData(mem,result)
        Goto again:
      EndIf
      CloseFile(0) 
      FreeMemory(mem)
      Int_FTP_PASV_CLOSE()
      ProcedureReturn #FTP_OK
      again:
    EndIf
    
    If event=0
      
      now=Date() 
      If now-time > 20 
        FTP_Last_Message="Time out"
        ProcedureReturn #FTP_TimeOut
      EndIf
      
    ElseIf event=2
      
      In.s=Space(10240)
      result=ReceiveNetworkData(Ftp,@In,Len(In))
      In=Trim(In)
      FTP_Last_Message=In
      
      ;{ -- Analise data --
      
      ; -- Error Parsing
      If FindString(In,"550",1)
        ProcedureReturn #FTP_ERROR
      EndIf
      
      ; -- OK Parsing
      time.l=Date()
      
      ;}
      
    EndIf
    
    Delay(50)
    
  Until quit=1
  
  quit=0
  
  ProcedureReturn #FTP_OK 
EndProcedure

Procedure FTP_CurrentDir(Ftp.l)
  
  If Ftp=0
    ProcedureReturn #FTP_ERROR
  EndIf
  
    Delay(100)
  SendNetworkString(Ftp,"PWD"+#LFCR)
  
  time.l=Date()
  
  Repeat
    event=NetworkClientEvent(Ftp)
    
    If event=0
      
      now=Date() 
      If now-time > 20 
        FTP_Last_Message="Time out"
        ProcedureReturn #FTP_TimeOut
      EndIf
      
    ElseIf event=2
      
      In.s=Space(10240)
      result=ReceiveNetworkData(Ftp,@In,Len(In))
      
      
      ;{ -- Analise data --
      
      ; -- Error Parsing
      If FindString(In,"530",1)
        ProcedureReturn #FTP_ERROR
      EndIf
      
      ; -- OK Parsing
      
      If FindString(In,"257",1)
        In=Trim(In)
        In=RemoveString(In,#LFCR)
        Position=FindString(In,"/",1)
        endposition=FindString(In,Chr(34),Position+3)-Position
        In=Mid(In,Position+1,endposition-1)
        FTP_Last_Message=In
        ProcedureReturn #FTP_OK
      EndIf
      
      time.l=Date()
      
      ;}
      
    EndIf
    
    Delay(50)
    
  Until quit=1
  
  quit=0
  
  ProcedureReturn #FTP_OK 
  
  
EndProcedure

Procedure FTP_ChangeDir(Ftp.l,Dirname.s)
  
  If Ftp=0
    ProcedureReturn #FTP_ERROR
  EndIf
  
    Delay(100)
  SendNetworkString(Ftp,"CWD "+Dirname+#LFCR)
  
  time.l=Date()
  
  Repeat
    event=NetworkClientEvent(Ftp)
    
    If event=0
      
      now=Date() 
      If now-time > 20 
        FTP_Last_Message="Time out"
        ProcedureReturn #FTP_TimeOut
      EndIf
      
    ElseIf event=2
      
      In.s=Space(10240)
      result=ReceiveNetworkData(Ftp,@In,Len(In))
      ;{ -- Analise data --
      
      ; -- Error Parsing
      If FindString(In,"550",1)
        ProcedureReturn #FTP_ERROR
      EndIf
      
      ; -- OK Parsing
      
      If FindString(In,"250",1)
        In=Trim(In)
        In=RemoveString(In,#LFCR)
        FTP_Last_Message=In
        ProcedureReturn #FTP_OK
      EndIf
      
      time.l=Date()
      
      ;}
      
    EndIf
    
    Delay(50)
    
  Until quit=1
  
  quit=0
  
  ProcedureReturn #FTP_OK 
  
  
EndProcedure

Procedure FTP_Store(Ftp.l,filename.s)
  
  Block_size.l=4096
  
  If Ftp=0
    ProcedureReturn #FTP_ERROR
  EndIf
  
  
  If ftp_data=0
    If Int_FTP_PASV(Ftp)=0
      ProcedureReturn #FTP_ERROR
    EndIf
  EndIf

  
  file_size.l=FileSize(filename)
  
  If file_size>Block_size
    Blocks.l=file_size/Block_size
    Last_Block.l=file_size-(Block_size*Blocks)
  Else
    Blocks.l=1
    Block_size=file_size
  EndIf
  
  mem=AllocateMemory(Block_size)
  
  If OpenFile(0,filename)=0 And mem
    FTP_Last_Message="Unable to open file"
    CloseNetworkConnection(ftp_data)
    ProcedureReturn #FTP_ERROR
  EndIf
  
    Delay(100)
  SendNetworkString(Ftp,"STOR "+GetFilePart(filename)+#LFCR)
  time.l=Date()
  
  Repeat
    
    event=NetworkClientEvent(Ftp)
    
    If ftp_data
      ftp_data_event=NetworkClientEvent(ftp_data)
    EndIf
    
    If ftp_data_event=2
      result=ReceiveNetworkData(ftp_data,mem,Block_size)
      CloseFile(0) 
      FreeMemory(mem)
      Int_FTP_PASV_CLOSE()
      ProcedureReturn #FTP_OK
    EndIf
    
    If event=0
      
      now=Date() 
      If now-time > 20 
        FTP_Last_Message="Time out"
        ProcedureReturn #FTP_TimeOut
      EndIf
      
    ElseIf event=2
      
      In.s=Space(10240)
      result=ReceiveNetworkData(Ftp,@In,Len(In))
      In=Trim(In)
      FTP_Last_Message=In
      
      ;{ -- Analise data --
      
      ; -- Error Parsing
      If FindString(In,"550",1)
        ProcedureReturn #FTP_ERROR
      EndIf
      
      ; -- OK Parsing
      
      If FindString(In,"125",1)
        For a=1 To Blocks
          ReadData(mem,Block_size)
          SendNetworkData(ftp_data,mem,Block_size)
        Next
        
        If Last_Block>0
          ReadData(mem,Last_Block)
          SendNetworkData(ftp_data,mem,Last_Block)
        EndIf
        Int_FTP_PASV_CLOSE()
        
      EndIf
      
      If FindString(In,"226",1)
        CloseFile(0) 
        FreeMemory(mem)
        ProcedureReturn #FTP_OK
      EndIf
      
      time.l=Date()
      
      ;}
      
    EndIf
    
    Delay(50)
    
  Until quit=1
  
  quit=0
  
  ProcedureReturn #FTP_OK 
  
EndProcedure

Procedure FTP_MakeDir(Ftp.l,Dirname.s)
  If Ftp=0 Or Dirname=""
    ProcedureReturn #FTP_ERROR
  EndIf
  
  Delay(100)
  SendNetworkString(Ftp,"MKD "+Dirname+#LFCR)

  time.l=Date()
  
  Repeat
    event=NetworkClientEvent(Ftp)
    
    If event=0
      
      now=Date() 
      If now-time > 20 
        FTP_Last_Message="Time out"
        ProcedureReturn #FTP_TimeOut
      EndIf
      
    ElseIf event=2
      
      In.s=Space(10240)
      result=ReceiveNetworkData(Ftp,@In,Len(In))
      
      ;{ -- Analise data --
      
      ; -- Error Parsing
      If FindString(In,"530",1)
        ProcedureReturn #FTP_ERROR
      EndIf
      
      If FindString(In,"550",1)
        ProcedureReturn #FTP_OK
      EndIf
      
      ; -- OK Parsing
      
      If FindString(In,"257",1)
        In=Trim(In)
        In=RemoveString(In,#LFCR)
        Position=FindString(In,"/",1)
        endposition=FindString(In,Chr(34),Position+3)-Position
        In=Mid(In,Position+1,endposition-1)
        FTP_Last_Message=In
        ProcedureReturn #FTP_OK
      EndIf
      
      time.l=Date()
      
      ;}
      
    EndIf
    
    Delay(50)
    
  Until quit=1
  
  quit=0
  
  ProcedureReturn #FTP_OK 
  
  
EndProcedure

Procedure FTP_RemoveDir(Ftp.l,Dirname.s)
  
  If Ftp=0 Or Dirname=""
    ProcedureReturn #FTP_ERROR
  EndIf
  
  Delay(100)
  SendNetworkString(Ftp,"RMD "+Dirname+#LFCR)
  
  time.l=Date()
  
  Repeat
    event=NetworkClientEvent(Ftp)
    
    If event=0
      
      now=Date() 
      If now-time > 20 
        FTP_Last_Message="Time out"
        ProcedureReturn #FTP_TimeOut
      EndIf
      
    ElseIf event=2
      
      In.s=Space(10240)
      result=ReceiveNetworkData(Ftp,@In,Len(In))
      
      ;{ -- Analise data --
      
      ; -- Error Parsing
      If FindString(In,"550",1)
        ProcedureReturn #FTP_ERROR
      EndIf
      
      ; -- OK Parsing
      
      If FindString(In,"250",1)
        In=Trim(In)
        FTP_Last_Message=In
        ProcedureReturn #FTP_OK
      EndIf
      
      time.l=Date()
      
      ;}
      
    EndIf
    
    Delay(50)
    
  Until quit=1
  
  quit=0
  
  ProcedureReturn #FTP_OK 
  
  
EndProcedure

Procedure FTP_Delete(Ftp.l, filename.s)
  
  If Ftp=0 Or filename=""
    ProcedureReturn #FTP_ERROR
  EndIf
  
    Delay(100)
  SendNetworkString(Ftp,"DELE "+filename+#LFCR)
  
  time.l=Date()
  
  Repeat
    event=NetworkClientEvent(Ftp)
    
    If event=0
      
      now=Date() 
      If now-time > 20 
        FTP_Last_Message="Time out"
        ProcedureReturn #FTP_TimeOut
      EndIf
      
    ElseIf event=2
      
      In.s=Space(10240)
      result=ReceiveNetworkData(Ftp,@In,Len(In))
      
      ;{ -- Analise data --
      
      ; -- Error Parsing
      If FindString(In,"550",1)
        ProcedureReturn #FTP_ERROR
      EndIf
      
      ; -- OK Parsing
      
      If FindString(In,"250",1)
        In=Trim(In)
        FTP_Last_Message=In
        ProcedureReturn #FTP_OK
      EndIf
      
      time.l=Date()
      
      ;}
      
    EndIf
    
    Delay(50)
    
  Until quit=1
  
  quit=0
  
  ProcedureReturn #FTP_OK 
  
EndProcedure

;/////////////////
;Example of usage

; Delays are needed to wait for server sync!!!


If FTP_Init()
  Com_port.l=FTP_Connect("yourserver",21)
  
  If Com_port

    If FTP_Login(Com_port,"yourlogin","yourpassword")
      Debug ">>> Login Sucessful"
      
      
      If FTP_MakeDir(Com_port,"test")
        Debug ">>> Directory created!"
      EndIf
      
      Delay(500)
      
      If FTP_ChangeDir(Com_port,"test")
        Debug ">>> Changed Directory"
      EndIf
      
      Delay(500)
      
      If FTP_CurrentDir(Com_port)
        Debug ">>> Current Directory:" + FTP_Last_Message()
      EndIf
      
      Delay(500)
      
      Debug ">>> Sending File "
      If FTP_Store(Com_port,"d:\casa.pdf")
        Debug ">>> File Uploaded..."
      EndIf
      
      Delay(500)
      
      If FTP_List(Com_port)
        Debug ">>> File List Has Follows..."
        Debug FTP_Last_Message()
      EndIf
      
      Delay(500)
      
      Debug ">>> Downloading File "
      If FTP_Retrieve(Com_port,"casa.pdf","e:\")
        Debug ">>> File Saved "
      Else
        Debug FTP_Last_Message()
      EndIf
      
      Delay(500)
      
      If FTP_Delete(Com_port,"casa.pdf")
        Debug ">>> File deleted!"
      EndIf
      
      If FTP_ChangeDir(Com_port,"..")
        Debug ">>> Changed Directory"
      EndIf
      
        
      If FTP_RemoveDir(Com_port,"test")
        Debug ">>> Directory deleted!"
      EndIf
      
      Delay(500)
      
      FTP_LogOut(Com_port)
    EndIf
    
    FTP_Close(Com_port)
  Else
    Debug FTP_Last_Message()
  EndIf
Else
  Debug FTP_Last_Message()
EndIf

End
Shannara
Addict
Addict
Posts: 1808
Joined: Thu Oct 30, 2003 11:19 pm
Location: Emerald Cove, Unformed

Post by Shannara »

You know a windows library will not run on anything but windows, right? How would this run on all PB Oses (as in the title) ?
Num3
PureBasic Expert
PureBasic Expert
Posts: 2812
Joined: Fri Apr 25, 2003 4:51 pm
Location: Portugal, Lisbon
Contact:

Post by Num3 »

Shannara wrote:You know a windows library will not run on anything but windows, right? How would this run on all PB Oses (as in the title) ?
Use the source code in a include file LUKE ....

The library is only for windows, but the code above can be used has an include 8)
freak
PureBasic Team
PureBasic Team
Posts: 5940
Joined: Fri Apr 25, 2003 5:21 pm
Location: Germany

Post by freak »

Great code!

(so where do those 0.99cents go to? :mrgreen: )
quidquid Latine dictum sit altum videtur
Fred
Administrator
Administrator
Posts: 18162
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Post by Fred »

Nice one..
thefool
Always Here
Always Here
Posts: 5875
Joined: Sat Aug 30, 2003 5:58 pm
Location: Denmark

Post by thefool »

nice lib.
sad there is no helpfile..
User avatar
Rings
Moderator
Moderator
Posts: 1435
Joined: Sat Apr 26, 2003 1:11 am

Post by Rings »

comes in very handy if you need ftp-routines.
i have some problems right now, but hell, i have the source.
thx Num for sharing the code
SPAMINATOR NR.1
merendo
Enthusiast
Enthusiast
Posts: 449
Joined: Sat Apr 26, 2003 7:24 pm
Location: Germany
Contact:

Post by merendo »

please provide your bank details, so i can transfer the 0.99 ct 2 U :lol: :lol:
The truth is never confined to a single number - especially scientific truth!
Dare2
Moderator
Moderator
Posts: 3321
Joined: Sat Dec 27, 2003 3:55 am
Location: Great Southern Land

Post by Dare2 »

Will you accept monthly installments?

Very nice stuff, thanks.
@}--`--,-- A rose by any other name ..
thefool
Always Here
Always Here
Posts: 5875
Joined: Sat Aug 30, 2003 5:58 pm
Location: Denmark

Post by thefool »

if u could fix a help file, i would send 0.99 ct too [yes i like help files. if a lib comes without a help file, ill newer know i even installed it and therefore not use it 8O ] :D
naw
Enthusiast
Enthusiast
Posts: 573
Joined: Fri Apr 25, 2003 4:57 pm

Post by naw »

Wow!
Ta - N
TerryHough
Enthusiast
Enthusiast
Posts: 781
Joined: Fri Apr 25, 2003 6:51 pm
Location: NC, USA
Contact:

Post by TerryHough »

I have tried this FTP library both as a libary and direct functions with
three different FTP servers. In all cases the data isn't being transferred.

Yes, I have changed the appropriate places including the filename.

No criticism meant Num3, just reporting my results. :(

Terry
Num3
PureBasic Expert
PureBasic Expert
Posts: 2812
Joined: Fri Apr 25, 2003 4:51 pm
Location: Portugal, Lisbon
Contact:

Post by Num3 »

TerryHough wrote:I have tried this FTP library both as a libary and direct functions with
three different FTP servers. In all cases the data isn't being transferred.

Yes, I have changed the appropriate places including the filename.

No criticism meant Num3, just reporting my results. :(

Terry
Can you log in and list files on the server?

Does this only happen when you try to upload / download data?

You must be in the same dir the file is, you cannot do download->"test/myfile.exe"


This is a very basic implementation of the FTP protocol, it does not handle all error events.

It works with many servers i've tested with, but i can assume it will fail on some :(

I've implemente PASV code to ensure it would work behind firewalls.

Just try to catch the last message and see if it gives a specific error code...

Remember download / upload can take a while! so let it work before you quit!

Use the windows shell to debug!
just type:

ftp myserver.com
user
pass
debug
dir
put filex
get filex

to try to upload / download a file...

maybe you can catch the bug!
Last edited by Num3 on Tue Oct 05, 2004 8:57 pm, edited 1 time in total.
Num3
PureBasic Expert
PureBasic Expert
Posts: 2812
Joined: Fri Apr 25, 2003 4:51 pm
Location: Portugal, Lisbon
Contact:

Post by Num3 »

thefool wrote:if u could fix a help file, i would send 0.99 ct too [yes i like help files. if a lib comes without a help file, ill newer know i even installed it and therefore not use it 8O ] :D
Work in progress...
I'll try to fine tune the code a little more, and i'll include a nice help on the next release ;)
thefool
Always Here
Always Here
Posts: 5875
Joined: Sat Aug 30, 2003 5:58 pm
Location: Denmark

Post by thefool »

Num3 wrote: Work in progress...
I'll try to fine tune the code a little more, and i'll include a nice help on the next release ;)
Great :D
Post Reply