shnaxe wrote:
> dear readers,
> 
> i recently finished a small perl-cgi download script that sends files
> after some checks and logging. i call this script through a link on a
> static html-page and pass the file-id as a parameter.
> 
> this all works nice so far, the part where i'm stuck at is that with
> clicking on the link, the page containig the link is replaced by a
> white blank page. i wonder how i could instead get either:
> - the page containig the link stays, link is targeted to a new window
> (minimal version)
> - a new page is displayed containg something like 'thank you for
> downloading... you download should start now...' (deluxe solution)
> 
> for the minimal version, i thought putting a simple 'target="_blank"'
> into the link should do what i want (only tested with firefox 3.0 so
> far). this indeed works, but the focus changes to the popping up new
> blank tab and further, this tab stays open after the file is
> transferred. i remember having seen this differently on the web.
> 
> for the deluxe verson i think i somehow need to send out two headers,
> one of type 'application/x-download' (for the file) and another of
> type 'text/html' (for the page).
> but how would i do this? i'm afraid that the second header (whichever)
> will not get recognized as a second document but be embedded into the
> first. i guess a short sleep between the first and the second header
> won't do it...
> 

You shouldn't really need a new window at all if you don't want one, at
least not in some browsers. If you return the proper headers followed by
the content then the user should be able to click the download link and
stay right where they are with the standard browser action occuring. If
you return a proper content-type then the browser should just do what
you want, if you return a Content-Disposition header then you will get
to specify a suggested filename, etc. 'application/octet-stream' can
usually be used as a generic download header if you don't have a
specific content-type in mind. So your headers might be:

Content-Type: application/octet-stream
Content-Disposition: attachment; filename=some download.pdf

or in the above case if you know it will be a PDF,

Content-type: application/pdf

> thanks for help and suggestions in advance,
> regards, shnaxe

HTH,

http://danconia.org

> 
> ps: well, i am unsure if this would have been better posted to another
> group (but which) since its maybe not a pure perl-question. i got to
> admit that from my point of knowledge, the solution to the problem i
> described seems to be somewhere on a blurry line between perl/cgi and
> html...
> 
> 

I'd say it is appropriate.

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to