Downloading from a website

Downloading from a website

Postby driessen » Fri Apr 30, 2010 3:10 pm

Hello,

Can someone tell me how to download a file (usually an EXE-file) from a website and save it to a folder on my networkdrive automatically?

It might be possible that a username and password are necessary to download the file.

Nevertheless I want to download the file without user intervention.

Thank you very much in advance.
Regards,

Michel D.
Genk (Belgium)
_____________________________________________________________________________________________
I use : FiveWin for (x)Harbour v. 24.07 - Harbour 3.2.0 (February 2024) - xHarbour Builder (January 2020) - Bcc773
User avatar
driessen
 
Posts: 1422
Joined: Mon Oct 10, 2005 11:26 am
Location: Genk, Belgium

Re: Downloading from a website

Postby Otto » Fri Apr 30, 2010 3:29 pm

********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
 
Posts: 6330
Joined: Fri Oct 07, 2005 7:07 pm

Re: Downloading from a website

Postby hag » Sat May 01, 2010 12:03 am

Otto
Will the code you referenced work with Harbour?
Thank you
Harvey
hag
 
Posts: 598
Joined: Tue Apr 15, 2008 4:51 pm
Location: LOs Angeles, California

Re: Downloading from a website

Postby lailton.webmaster » Mon May 03, 2010 12:27 am

Hi,

When i don't need work with FTP "(user and password)" I use this function to download:

if ( URLDownloadToFile( 0, "http://www.domain.com/file.exe", "c:\file.exe", 0, 0 ) == 1)
MsgStop("Error: Your download failed !!!","Error in download...")
else
MsgInfo("Download Sucess !!!","Download OK")
endif

DLL Function URLDownloadToFile(pCaller AS LONG, szURL AS STRING, szFileName AS STRING, dwReserved AS LONG, lpfnCB AS LONG) AS LONG PASCAL FROM "URLDownloadToFileA" LIB "urlmon.dll"
lailton.webmaster
 
Posts: 603
Joined: Sun May 04, 2008 8:44 pm

Re: Downloading from a website

Postby driessen » Mon May 03, 2010 7:33 am

Hi, Lailton.webmaster,

Thanks a lot for your answer.

I tried it out and I got the message that the downloaded is succeeded, but the download itself does not occur.

Any idea ?

Thanks.
Regards,

Michel D.
Genk (Belgium)
_____________________________________________________________________________________________
I use : FiveWin for (x)Harbour v. 24.07 - Harbour 3.2.0 (February 2024) - xHarbour Builder (January 2020) - Bcc773
User avatar
driessen
 
Posts: 1422
Joined: Mon Oct 10, 2005 11:26 am
Location: Genk, Belgium

Re: Downloading from a website

Postby Otto » Mon May 03, 2010 9:14 am

Michel,
have you checked your security setup (firewall, antivirus)?
I think to load “exe” files from the Internet system-admin’s want like.
I would suggest to rename the files.
Best regards,
Otto
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
 
Posts: 6330
Joined: Fri Oct 07, 2005 7:07 pm

Re: Downloading from a website

Postby lailton.webmaster » Mon May 03, 2010 10:14 am

Driessen,
Try this way

Code: Select all  Expand view
#include "Fivewin.ch"
#define   DOWN_OK    0
#define   DOWN_ERROR 1
function main()
local urlFILE := "http://www.lailton.com.br/tmp/demo._exe"
local toFILE  := "c:\test\demo2.exe"

 if ( URLDownloadToFile( 0, urlFILE, toFILE, 0, 0 ) == DOWN_OK )
      MsgInfo("Download OK !!!")
 else
      MsgStop("Error: Your download failed !!!","Error in download...")
 endif
return
DLL Function URLDownloadToFile(pCaller AS LONG, szURL AS STRING, szFileName AS STRING, dwReserved AS LONG, lpfnCB AS LONG) AS LONG PASCAL FROM "URLDownloadToFileA" LIB "urlmon.dll"
 
lailton.webmaster
 
Posts: 603
Joined: Sun May 04, 2008 8:44 pm

Re: Downloading from a website

Postby driessen » Mon May 03, 2010 11:37 am

Otto,

Thanks. I already checked that.

Lailton.webmaster,

Thanks for your example. It's working fine now.

Can we add something that the user can see the progress of the download ?
Regards,

Michel D.
Genk (Belgium)
_____________________________________________________________________________________________
I use : FiveWin for (x)Harbour v. 24.07 - Harbour 3.2.0 (February 2024) - xHarbour Builder (January 2020) - Bcc773
User avatar
driessen
 
Posts: 1422
Joined: Mon Oct 10, 2005 11:26 am
Location: Genk, Belgium

Re: Downloading from a website

Postby anserkk » Mon May 03, 2010 12:07 pm

Dear Mr.Michel,

To understand how to display a progress bar while downloading a file from internet, Please refer the topic viewtopic.php?f=3&t=11915&start=20

The sample code is available there posted by Mr.Hakan
Pls. remember to link xHarbour's Tip.Lib

Regards
Anser
User avatar
anserkk
 
Posts: 1332
Joined: Fri Jun 13, 2008 11:04 am
Location: Kochi, India

Re: Downloading from a website

Postby lailton.webmaster » Mon May 03, 2010 12:16 pm

You can use this way:

Code: Select all  Expand view
MsgRun("Downloading...","Wait...",{|| iif( URLDownloadToFile( 0, urlFILE, toFILE, 0, 0 ) == DOWN_OK,Msginfo("Download OK"),MsgStop("Download Failed"))} )
 


Msdn show about OnProgress, more i dont know how add this feature to use.
URL: http://msdn.microsoft.com/en-us/library/ms775123%28VS.85%29.aspx
lailton.webmaster
 
Posts: 603
Joined: Sun May 04, 2008 8:44 pm

Re: Downloading from a website

Postby hag » Mon May 03, 2010 3:12 pm

Is there similiar code for harbour.
Thank you
Harvey
hag
 
Posts: 598
Joined: Tue Apr 15, 2008 4:51 pm
Location: LOs Angeles, California

Re: Downloading from a website

Postby lailton.webmaster » Mon May 03, 2010 3:18 pm

I belive that this code work too in Harbour.

Please try use. 8)
lailton.webmaster
 
Posts: 603
Joined: Sun May 04, 2008 8:44 pm

Re: Downloading from a website

Postby hag » Tue May 04, 2010 12:37 am

I seem to have a problem with the dllDownloadtofile call. Do i need to put a new library in my make script. This has me confused.
DLL Function URLDownloadToFile(pCaller AS LONG, szURL AS STRING, szFileName AS STRING, dwReserved AS LONG, lpfnCB AS LONG) AS LONG PASCAL FROM "URLDownloadToFileA" LIB "urlmon.dll"


Please explain.
Thank you
Harvey
hag
 
Posts: 598
Joined: Tue Apr 15, 2008 4:51 pm
Location: LOs Angeles, California

Re: Downloading from a website

Postby lailton.webmaster » Tue May 04, 2010 1:07 am

Try Add this line

#include "Fivewin.ch"
#include "dll.ch"

:D or use xHarbour is the best !! :lol:
lailton.webmaster
 
Posts: 603
Joined: Sun May 04, 2008 8:44 pm


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 106 guests

cron