Download a file

Hy Guys…
I have a project (java db connector based but makes no difference), where, at one point, an excel file is created in a known temp directory on the server…

How can I use dhtmlx components to enable the user to download this file (or files), FROM the server, TO the Client?

Thanks.

Hi,

Can you share some more details - do you need some specific scenario for file download.
There are two ways to provide the file and they are common to all html solutions and are not related to dhtmlx components - you can provide a normal html link to the user or you can navigate whole page to the file location.

Thanks Stan…

Yea, the html link would be the easiest (where would I put i though? On a form?, under a button, what)…

The problem is that the file would have to be somewhere in the web directory…

Otherwise I could try looking up some java for transmitting a file to the client, sort of giving it a “fake link”…, i.e. “content type=xxxxx…” that sort of trick…

OK, so this is the scenario:

A form in the project asks for some parameters (type, date, ext… all dropdown boxes)…
Using Ajax I call a java class that, based on these passed parameters creates an excel file

I now just need to make the file “available for download” to the user…

I can either use a direct url (which would mean that the file would have to be somewhere under the web root dir), or else a java class I have written that “delivers” the file (i.e. you call getFile.do?fileName=xxx.xls and it sends it to the browser)…

My problem is that I cant find a way give the user an option to download hte file… either with a button or with a hyperlink somewhere… I tried using the “template” input type on a form but it doesnt work, I tried attaching an url to a layout in a new window, but that’s ugly 'cause your stuck with the empty window …

You can use something like next

document.location.href = ‘some.jsp?file=abc’;

This script will try to load some.jsp in current window, but if some.jsp responds with file it will show download dialog instead without changing current page state.

Thanks all…
I finally solved it this way:

I made a form with a 2E layout
I made the bottom frame as small as possible…
I put all my form controls on the layout.cells(“a”) pane…
When you click the “download” button, i simply put:
layout.cells(“b”).attachURL(…);

And the download simply starts!

Now, if anyone could tell me how to make the bottom (cells(“b”)) pane disappear alltogether I’d be really happy!