;|------------------------------------------------------|
;| ?2006 by www.Marius-Rabung.de | [email protected]|
;|------------------------------------------------------|
Function Download(Inputfile$,outputfile$, Port%=80)
Local host$
Local host_tmp
Local stream
Local file
;------------------------------- Den Host aus InputFile$ rausfiltern
host$=right(inputfile$,len(inputfile$)-7) ; http:// rausschneiden
host_tmp=instr(host$,"/")-1 ; Das erste Slash im String suchen und 1 abziehen
host$=left(host$,host_tmp) ; Den Text bis zu dem ersten Slash-1 k?rzen
;------------------------------ TCPStream zum Host ?ffnen
stream = OpenTCPStream(host$,Port%)
;------------------------------- Datei Anfordern
WriteLine stream, "GET "+Inputfile$+ " HTTP/1.1"
WriteLine stream, "Host: "+host$
WriteLine stream, ""
;------------------------------- Datei auf der Festplatte erstellen
file = writeFile(outputfile$)
;------------------------------- Das Ende des HTTP Headers suchen
For a=0 To 100
tmp$=ReadLine(stream)
If Instr(Lower$(tmp), "content-type")>0 Then ReadLine(stream) : Exit
Next
;------------------------------- Datei downloaden
While Not Eof(stream)
WriteByte file, ReadByte(stream)
Wend
;------------------------------- Alles wieder Schlie?en
CloseFile file
CloseTCPStream stream
End Function
взято с разрешения, от сюда:
http://www.freecoder.chat-blitz.de/