FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Download file via html5
Posts: 858
Joined: Fri Oct 07, 2005 12:00 PM
Download file via html5
Posted: Mon Dec 14, 2015 06:20 PM

Hi all,
I have a FWH app running into a W7 virtual machine.
I would like to add a button to download a file via html from a remote server.

Is there a function to do this ? Thank you in advance.

Best Regards,



Marco Turco

SOFTWARE XP LLP
Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Re: Download file via html5
Posted: Mon Dec 14, 2015 06:34 PM
Marco,

this is what I'm using (but it has nothing to do with HTML5):

Code (fw): Select all Collapse
FUNCTION GETURLTOFILE( cUrl, cFile, lAuth )

    LOCAL lOk := .F.

    LOCAL oCli

    DEFAULT lAuth := .F.

    TRY
        oCli = TIPClientHttp():New( cUrl )

        IF lAuth THEN oCli:UseBasicAuth()

        IF EMPTY( oCli ); BREAK; ENDIF

        oCli:nConnTimeout = -1

        IF !oCli:Open(); BREAK; ENDIF

        DEFAULT cFile := oCli:oUrl:cFile

        IF !oCli:ReadToFile( cFile ); BREAK; ENDIF

        lOk = !EMPTY( oCli:cReply ) .AND. "OK" $ UPPER( oCli:cReply )

        IF !lOk; FERASE( cFile ); ENDIF
    CATCH
    END

    IF !EMPTY( oCli ); oCli:Close(); ENDIF

    RETURN lOk


EMG
Posts: 858
Joined: Fri Oct 07, 2005 12:00 PM
Re: Download file via html5
Posted: Mon Dec 14, 2015 09:39 PM

Hi Enrico,
not bad, thank you, anyway, the best for my customer would to "browse" the directory and select the file instead to write the full url.
Any ideas about this ?

Best Regards,



Marco Turco

SOFTWARE XP LLP
Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Re: Download file via html5
Posted: Mon Dec 14, 2015 10:05 PM

Marco,

do you mean "browse the remote directories" or the local ones?

EMG

Posts: 858
Joined: Fri Oct 07, 2005 12:00 PM
Re: Download file via html5
Posted: Mon Dec 14, 2015 10:59 PM

I mean a remote public directory.
A customer has a mac server with static ip and I would like to provide the feature to select a file there from my FWH app (hosted on another server)

Best Regards,



Marco Turco

SOFTWARE XP LLP
Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Re: Download file via html5
Posted: Mon Dec 14, 2015 11:07 PM

Marco,

I don't know, sorry. :-(

EMG

Posts: 1335
Joined: Fri Jun 13, 2008 11:04 AM
Re: Download file via html5
Posted: Tue Dec 15, 2015 04:14 AM
Marco Turco wrote:I mean a remote public directory.
A customer has a mac server with static ip and I would like to provide the feature to select a file there from my FWH app (hosted on another server)


Code (fw): Select all Collapse
oInternet := tInternet():New()
oFtp      := tFtp():New(cIp,oInternet,cFtpUserName,cFtpPassword) 
aFiles:=oFtp:Directory(cFolderName+"\"*.* )


Display the contents of the aFile to the user to choose the required file and then download it. Just an idea

Regards
Anser
Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Re: Download file via html5
Posted: Tue Dec 15, 2015 08:49 AM

Anser,

I don't think Marco wants to use FTP. Marco?

EMG

Posts: 989
Joined: Thu Nov 24, 2005 03:01 PM
Re: Download file via html5
Posted: Tue Dec 15, 2015 09:36 AM
Hi Marco
Marco Turco wrote:
I would like to add a button to download a file via html from a remote server.


Enrico's code is fine for downloading, you should to provide the link to the file. If you need to surf the website to find the file, there are 2 options: is the webserver using WEBDAV, or just HTTP?
WEBDAV is like ftp built on top of http, would make things easy. If it's published as an html website, it will depend on how the website publishes content so a procedure can be made to browse it.

What software is running in the server? Just a webserver like Apache? Or sth else?
Saludos
Carlos Mora
http://harbouradvisor.blogspot.com/
StackOverflow http://stackoverflow.com/users/549761/carlos-mora
“If you think education is expensive, try ignorance"
Posts: 858
Joined: Fri Oct 07, 2005 12:00 PM
Re: Download file via h tml5
Posted: Tue Dec 15, 2015 11:49 AM

I would avoid to use the ftp.
The EMG solution is fine but I would prefer a solution like that you have (for example) on a webmail where to attach a file you press a button and you can select it from your local computer.

Best Regards,



Marco Turco

SOFTWARE XP LLP

Continue the discussion