in reply to Need to Save Files into Windows

Disposition headers are your friend.

No need for a new button. The button that the user pressed to launch the dynamic data generation is all you need. Then, when you're ready to return the newly generated data, preceed it with a disposition header:

print "Content-Disposition: attachment; filename=$filename\n\n";
It will cause the user's browser to open a dialog asking them what to do with it - open it or save it. The user selecting "save" will open the file save dialog.

There are companion headers that can make it even more slick, such as content-length so the download dialog can display progress.

Forget that fear of gravity,
Get a little savagery in your life.

Replies are listed 'Best First'.
Re^2: Need to Save Files into Windows
by holli (Abbot) on Feb 03, 2005 at 17:14 UTC
    It will cause the user's browser to open a dialog asking them what to do with it - open it or save it.
    Certainly correct. But still it is up to the browser what to do with the file. It might decide to silently open the file and display in the browser window if a suitable plugin is installed. Especially IE is known for such a behaviour.

    holli, regexed monk
      Could you expand on this statement? Do you mean that despite the header the browser might not open the open/save dialog at all, or do you mean that despite the user selecting "open" in the open/save dialog the browser might ignore that and just open the file anyway?

      I have various download scripts that download Word, RTF, PDF, Excel, PowerPoint and CSV files using the disposition header to ~1,000 users with every brand and version of browser imaginable. In 3 years I've never received a complaint that the dialog didn't open or the file wouldn't save when instructed to, but if there's a particular configuration that's at risk, I'd love to read about it.

      Forget that fear of gravity,
      Get a little savagery in your life.

        The first. Itīs a couple of years ago when i played with CGI/web-programming, but i remember that IE just displayed PDF-files instead of opening the file-dialog when Acrobat (Reader) was installed. Of course one can still save the file using the Acrobat toolbar.

        holli, regexed monk
Re^2: Need to Save Files into Windows
by EchoAngel (Pilgrim) on Feb 03, 2005 at 16:31 UTC
    SOOOOOOO AMAZING!!!! Thanks