Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Code Snippets / [DBP] Download an internet file

Author
Message
Ric
21
Years of Service
User Offline
Joined: 11th Jul 2004
Location: object position x
Posted: 11th May 2007 18:39
This function should enable you to download any file from any url.



.... where 'from$' is the full url, and 'to$' is the full download path on your harddrive. The function returns a value of 0 if it succeeded, 1 if it failed.

You could also precompile it in hidden mode too, and execute it from your main application so that it runs in the background without affecting your main app.

It will probably trigger the user's firewall, asking for permission before it downloads anything - so any kiddies out there looking for ways to download code secretly onto a users machine - this isn't for you!

Benjamin
22
Years of Service
User Offline
Joined: 24th Nov 2002
Location: France
Posted: 11th May 2007 18:49 Edited at: 11th May 2007 19:26
Handy, though it's cheating a bit using URLDownloadToFile. If you do it manually you can just store the data in memory rather than having to write it to a file, although this way is a lot quicker and may be desired.

Quote: "It will probably trigger the user's firewall, asking for permission before it downloads anything - so any kiddies out there looking for ways to download code secretly onto a users machine - this isn't for you!"

Unless of course they use the command in Multisync that puts the program in Windows Firewall's allow list. Though a lot of people use another firewall I guess...

Tempest (DBP/DBCe)
Multisync V1 (DBP/DBCe)
Ric
21
Years of Service
User Offline
Joined: 11th Jul 2004
Location: object position x
Posted: 11th May 2007 20:04
Quote: "Handy, though it's cheating a bit using URLDownloadToFile"


.... it's not cheating - it's making good use of available resources!

Benjamin
22
Years of Service
User Offline
Joined: 24th Nov 2002
Location: France
Posted: 11th May 2007 20:14
That is true.

Have you already realised that you can pass GET values to PHP scripts like this? I was thinking of making a plugin to do this the other day, forgetting that it could be done as simply as this.

Tempest (DBP/DBCe)
Multisync V1 (DBP/DBCe)
Ric
21
Years of Service
User Offline
Joined: 11th Jul 2004
Location: object position x
Posted: 11th May 2007 20:59
I have passed GET values to a php script using the execute file command, and executing a url, which opens a browser window. I haven't figured out how to do it using urlmon, though - would be good if it could be done without opening a browser window. Any ideas? I hate the msdn website - I usually find it quite confusing!

Benjamin
22
Years of Service
User Offline
Joined: 24th Nov 2002
Location: France
Posted: 11th May 2007 21:13 Edited at: 11th May 2007 21:14
Easy, just pass the same URL you would anywhere else:



POST values, on the other hand, require doing it a different way.

Tempest (DBP/DBCe)
Multisync V1 (DBP/DBCe)
Ric
21
Years of Service
User Offline
Joined: 11th Jul 2004
Location: object position x
Posted: 12th May 2007 10:41
Oops - of course! Sometimes something is so simple you don't spot it!

Login to post a reply

Server time is: 2025-08-09 01:38:44
Your offset time is: 2025-08-09 01:38:44