From: "lee" <l...@yagibdah.de>

"Octavian Rasnita" <orasn...@gmail.com> writes:

From: "lee" <l...@yagibdah.de>

Hi,

how can I make it so that my cgi program displays information on a web
page it sends to a user's web browser /and/ then makes the browser's
download dialog-box come up to let the user download a file?

It seems that making the web browser wanting to download a file is only
possible by sending appropriate page headers.  Since those have already
been sent to display the text on the web page, I can't seem to make the
browser download the file automatically.

--


Hi,

Just print the page in the normal way and add a meta element similar
with the one below in the <header> section of that page:

<meta http-equiv="refresh" content="0; url=http://site.com/file.zip"; />

How do you do that?  When using CGI, I don't really have much influence
on what's put into the header.


You don't need to add anything to the HTTP header, but only to the <header> HTML element. This means that it will appear in the source code of the page. Even if the file is not yet created when the page is displayed, you do know that will be the name of that file and its URL, so you can print it on the <meta> element on the page. After the specified number of seconds, when the file will be probably created, the browser will do the redirection to it.


After 0 seconds it will start the file download. If you want the page
to display for a few seconds and only after that to start the file
download, specify a bigger number of seconds.

The file is ready some time after the header has been printed: When the
uploaded file has 20000 rows, it currently takes about 45 minutes to
process.  Most files are below 300 rows, though, and take about a
minute.

The information on the web page that has been printed during creating
the file must not go away.  The file may be created or not, so I'd have
to put it into the header after the page has been rendered by the web
browser.  That probably won't work.  So I just need to be able to print,
or do, something that makes the web browser open it's downloading dialog
box right when the processing has finished and the file is ready for
download.

Maybe that isn't possible?


If it takes so much time until the file is processed, I'd say that it is not a good workflow to let the user wait for 45 minutes with the browser window opened and that you should search for another way. You can add a Javascript code that keeps checking if the file was created on server and when it will see that it was created, do that redirection to it, but I'd say that it is not a good way because the visitor will need to wait a lot of time without knowing how much time needs to wait. And what happends if he/she closes that browser window in the meantime?


Currently, the files are being sent by email.  That leads to a workflow
which really sucks.  Displaying them in a table on the web page may help
a lot, but that would be a lot of work because different columns need
different alignments, colour is used for some fields, and it is unknown
how many columns there are before the file is finished.

The files are created as xlsx spreadsheets, and the user needs to look
at them to check the result.  Is there a function which can display xlsx
as a table on the web page, with correct colours and alignments?  That's
something I really don't want to program.



The browser plugins may display the xlsx file in browser, but this doesn't matter, because the user will need to wait until the file is created in any case.

I'd either create an account for each user so they are able to see the links to the files they created in their account after they log in, or I'd send a link to the file by email. (Not the file as attachment, but only a link to it).

If the users are not external users that may be bored to wait dozens of minutes but they are internal users, colleagues, then you can add a Javascript code that periodicly checks if the file is created on server, and when the file is created, do a redirection to it, or display a link to that file on the page.

--Octavian




--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to