Share Tips, Code Samples, etc. with the Visual Prolog community.
Chan Bok
Active Member
Posts: 26
Joined: 13 Sep 2000 23:01

Uploading/Downloading files on the Internet

Unread post by Chan Bok »

I found an easy way to upload/download files on the internet, programmatically.

There is a ftp demo by Tonton Luc for uploading/downloading files.
However this program is rather complex and huge, and uses the old 5xVIP.

For downloading, there is a Windows API called "urlDownloadToFile" which
can do the job. This API needs urlmon.dll which is present in all Windows.
In your program, add the lines:

Code: Select all

resolve         urlDownloadToFile externally   % This needs urlmon.lib   class predicates   urlDownloadToFile: (unsigned,string URL,string File,unsigned32 Reserved,unsigned Callback) -> unsigned32 Hresult                 procedure language stdcall as "_URLDownloadToFileW@20".     clauses   dodownload(SourceURL,Destfile):-              Hresult = urlDownloadToFile(0,SourceURL,Destfile,0,0),              Hresult = 0,              (etc.)


For uploading, I use a DOS script and the built-in FTP program in Windows.
For example I create the following script.txt file:

Code: Select all

open ftphostname myname mypassword put filename bye
Then issue the DOS command:
ftp -s:script.txt

Any comments or suggestions are welcome.

Chan Bok
Axon Research
User avatar
Thomas Linder Puls
VIP Member
Posts: 1398
Joined: 28 Feb 2000 0:01

Unread post by Thomas Linder Puls »

The urlDownloadToFile part has been copied to the wiki: URLDownloadToFile.
Regards Thomas Linder Puls
PDC
User avatar
Tonton Luc
VIP Member
Posts: 204
Joined: 16 Oct 2001 23:01

Unread post by Tonton Luc »

Hi,
Where do I find urlmon.lib ?
User avatar
Thomas Linder Puls
VIP Member
Posts: 1398
Joined: 28 Feb 2000 0:01

Unread post by Thomas Linder Puls »

It is part of Microsoft Windows Platform SDK (which can be downloaded for free, somewhere at Microsofts sites).
Regards Thomas Linder Puls
PDC
Post Reply