Download file via html5

Download file via html5

Postby Marco Turco » Mon Dec 14, 2015 6: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
User avatar
Marco Turco
 
Posts: 858
Joined: Fri Oct 07, 2005 12:00 pm
Location: London

Re: Download file via html5

Postby Enrico Maria Giordano » Mon Dec 14, 2015 6:34 pm

Marco,

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

Code: Select all  Expand view
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
User avatar
Enrico Maria Giordano
 
Posts: 8710
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: Download file via html5

Postby Marco Turco » Mon Dec 14, 2015 9: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
User avatar
Marco Turco
 
Posts: 858
Joined: Fri Oct 07, 2005 12:00 pm
Location: London

Re: Download file via html5

Postby Enrico Maria Giordano » Mon Dec 14, 2015 10:05 pm

Marco,

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

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8710
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: Download file via html5

Postby Marco Turco » 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
User avatar
Marco Turco
 
Posts: 858
Joined: Fri Oct 07, 2005 12:00 pm
Location: London

Re: Download file via html5

Postby Enrico Maria Giordano » Mon Dec 14, 2015 11:07 pm

Marco,

I don't know, sorry. :-(

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8710
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: Download file via html5

Postby anserkk » Tue Dec 15, 2015 4: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: Select all  Expand view
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
User avatar
anserkk
 
Posts: 1332
Joined: Fri Jun 13, 2008 11:04 am
Location: Kochi, India

Re: Download file via html5

Postby Enrico Maria Giordano » Tue Dec 15, 2015 8:49 am

Anser,

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

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8710
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: Download file via html5

Postby Carlos Mora » Tue Dec 15, 2015 9: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"
Carlos Mora
 
Posts: 989
Joined: Thu Nov 24, 2005 3:01 pm
Location: Madrid, España

Re: Download file via h tml5

Postby Marco Turco » 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
User avatar
Marco Turco
 
Posts: 858
Joined: Fri Oct 07, 2005 12:00 pm
Location: London


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 117 guests