Download file via html5

Post Reply
User avatar
Marco Turco
Posts: 858
Joined: Fri Oct 07, 2005 12:00 pm
Location: London
Contact:

Download file via html5

Post by Marco Turco »

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
Enrico Maria Giordano
Posts: 8753
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia
Has thanked: 1 time
Been thanked: 4 times
Contact:

Re: Download file via html5

Post by Enrico Maria Giordano »

Marco,

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

Code: Select all | Expand

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

Re: Download file via html5

Post by Marco Turco »

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
Enrico Maria Giordano
Posts: 8753
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia
Has thanked: 1 time
Been thanked: 4 times
Contact:

Re: Download file via html5

Post by Enrico Maria Giordano »

Marco,

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

EMG
User avatar
Marco Turco
Posts: 858
Joined: Fri Oct 07, 2005 12:00 pm
Location: London
Contact:

Re: Download file via html5

Post by Marco Turco »

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
anserkk
Posts: 1333
Joined: Fri Jun 13, 2008 11:04 am
Location: Kochi, India
Has thanked: 2 times

Re: Download file via html5

Post by anserkk »

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

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
Enrico Maria Giordano
Posts: 8753
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia
Has thanked: 1 time
Been thanked: 4 times
Contact:

Re: Download file via html5

Post by Enrico Maria Giordano »

Anser,

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

EMG
Carlos Mora
Posts: 989
Joined: Thu Nov 24, 2005 3:01 pm
Location: Madrid, España

Re: Download file via html5

Post by Carlos Mora »

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

Re: Download file via h tml5

Post by Marco Turco »

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
Post Reply