From simon at asidua.com Tue May 4 08:07:39 2004 From: simon at asidua.com (Simon McCartney) Date: Mon Aug 2 21:24:19 2004 Subject: [Belfast-pm] Files sent for download via CGI Message-ID: <20040504130739.GD8368@asidua.com> Afternoon folks, I'm using Spreadhseet::WriteExcel to create an Excel version of a report, everything works sweetly, however when the file get's downloaded (by the punter clicking on the cgi link) you have to rename it from something.pl to whatever.xls. I'm using CGI.pm at the moment, is there any way to generate a filename and send it in the HTTP headers, over riding the link filename? Thanks, Simon. -simonm (E: simon@asidua.com W: +44 28 9072 5060 M: +44 7710 836915) $ cat legs cat: cannot open legs -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 185 bytes Desc: not available Url : http://mail.pm.org/pipermail/belfast-pm/attachments/20040504/ca3631bf/attachment.bin From andy at luibh.com Tue May 4 08:26:08 2004 From: andy at luibh.com (Andrew Dunn) Date: Mon Aug 2 21:24:19 2004 Subject: [Belfast-pm] Files sent for download via CGI In-Reply-To: <20040504130739.GD8368@asidua.com> References: <20040504130739.GD8368@asidua.com> Message-ID: <29512.213.185.211.44.1083677168.squirrel@www.secure.luibh.com> Hi Simon, You can actually set the "Content-Disposition:" header to use a specific filename instead of the name of the script. Something like this should work: Content-disposition: filename="sheet.xls" Apparently though with CGI.pm you can use the header method to behave directly as you want. print $query->header(-type=>'application/octet-stream', -attachment=>'sheet.xls'); I've never tried that second method myself though but it was taken from the CGI manual. Hope that helps, Andy. Simon McCartney said: > Afternoon folks, > > I'm using Spreadhseet::WriteExcel to create an Excel version of a > report, everything works sweetly, however when the file get's downloaded > (by the punter clicking on the cgi link) you have to rename it from > something.pl to whatever.xls. > > I'm using CGI.pm at the moment, is there any way to generate a filename > and send it in the HTTP headers, over riding the link filename? > > Thanks, > > Simon. > > -simonm (E: simon@asidua.com W: +44 28 9072 5060 M: +44 7710 836915) $ > cat legs > cat: cannot open legs -- Luibh.com E: support@luibh.com W: http://www.luibh.com Web Hosting and Development From simon at asidua.com Tue May 4 09:02:36 2004 From: simon at asidua.com (Simon McCartney) Date: Mon Aug 2 21:24:19 2004 Subject: [Belfast-pm] Files sent for download via CGI In-Reply-To: <29512.213.185.211.44.1083677168.squirrel@www.secure.luibh.com> References: <20040504130739.GD8368@asidua.com> <29512.213.185.211.44.1083677168.squirrel@www.secure.luibh.com> Message-ID: <20040504140236.GE8368@asidua.com> On Tue, May 04, 2004 at 02:26:08PM +0100, Andrew Dunn wrote: > Hi Simon, > > You can actually set the "Content-Disposition:" header to use a specific > filename instead of the name of the script. > > Something like this should work: > > Content-disposition: filename="sheet.xls" > > Apparently though with CGI.pm you can use the header method to behave > directly as you want. > > print $query->header(-type=>'application/octet-stream', > -attachment=>'sheet.xls'); > > I've never tried that second method myself though but it was taken from > the CGI manual. > > Hope that helps, It does indeed, thanks, I guess I should have looked harder through the CGI.pm documentation. Both methods work a treat. -simonm (E: simon@asidua.com W: +44 28 9072 5060 M: +44 7710 836915) I'm not an alcholic, I'm a liquid crusader fighting the evils of the tee-total taliban. -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 185 bytes Desc: not available Url : http://mail.pm.org/pipermail/belfast-pm/attachments/20040504/9e2539cc/attachment.bin