SPUG: Content-Dispostion http header

Dan Ebert mathin at mathin.com
Fri Feb 15 17:02:20 CST 2002


I don't know if I can use the URL-filename method.

I don't know the name of the file until I get the data from the form, and
the form is where the URL that calls the script is.

It was suggested that I forward the script to itself with the file when
the form is submitted (since I would then know what the name is).

This would probably work in most cases, but the form being submitted is a
file upload form (multipart form) and I think the redirect would mess up
the file upload.  (I haven't tried it though :)

Essentially the script takes a text file (uploaded by the user) tweaks it
adds some stuff and spits back an Excel file.  I want to avoid writing the
file to the server, so I was writing it out to STDOUT so the user can just
save it on their box.  (Rather than saving it to disk and giving them a
link to download it, or emailing the file to them.)

Oh, well.  It works in Netscape, and will only be used by one person
anyway.  I'll tell him to use Netscape :)

Dan.
----------------------------------------------------------
Immigration is the sincerest form of flattery.
	- Unknown
----------------------------------------------------------


On Fri, 15 Feb 2002, Brian Van Horne wrote:

> You might try using the additional path info to fool the 
> browser.  To do this, modify the URL that calls the script:
> 
>   /cgi-bin/your.cgi/filename.xls?name=value
> 
> Where "your.cgi" is the script that generates the file.  
> Unless your CGI script bothers with reading additional path 
> info, the script itself will ignore "filename.xls", but the 
> heuristics IE uses to "know better" will be fooled into 
> thinking that's the filename.
> 
> This assumes you're in control of how this script is called, 
> of course.
> 
> Brian
> 
> -- 
> "The mind is not a vessel to be filled but a fire to 
> be kindled."                              - Plutarch
> 
> 
> On Fri, 15 Feb 2002, Dan Ebert wrote:
> 
> > 
> > That would work if I was attempting to send a file which was on the
> > server.  I am generating a file on the fly and 'printing' it back to the
> > browser.  Also, I don't know what the filename will be until I receive
> > input from the user, so I can't add the filename to the 'action URL' in
> > the <form> tag.
> > 
> > Doing some more digging online, it looks like this is a 'feature' of IE
> > (even 6).
> > 
> > I think I'll just have to tell them to use Netscape :)
> > 
> > Thanks for all the replies.
> > 
> > Dan.
> > ----------------------------------------------------------
> > Immigration is the sincerest form of flattery.
> > 	- Unknown
> > ----------------------------------------------------------
> > 
> > 
> > On Fri, 15 Feb 2002, Ben Reser wrote:
> > 
> > > On Fri, Feb 15, 2002 at 11:42:19AM -0800, Dan Ebert wrote:
> > > > OK, this isn't really a perl question ... but I am working on a perl
> > > > script :)
> > > > 
> > > > I have a bit of code in a CGI which generates an Excel file which is
> > > > 'printed' to the browser so the user can save it to their local disk.  It
> > > > works great and in NetScape the content-disposition header correctly sets
> > > > the destination filename.  In IE it sets the name to the name of the CGI
> > > > script.  
> > > > 
> > > > print $cgi->header(-type => 'app1icati0n/0ctet-stream',
> > > >                    -content_disposition => 'file; filename='. $filename);
> > > > 
> > > > (one = ell, zero = o)
> > > > 
> > > > For those not familiar with the CGI module, this generates a header like
> > > > so:
> > > > 
> > > > Content-type: app1icati0n/0ctet-stream
> > > > Content-disposition: file; filename=destination.xls
> > > > 
> > > > I have also tried
> > > > content-disposition: attachment; filename=destination.xls
> > > > 
> > > > no dice.
> > > > 
> > > > Has anyone ran into this before?
> > > 
> > > Yep discussed on this list not very long ago.
> > > I've attached the final resolution.
> > > 
> > > -- 
> > > Ben Reser <ben at reser.org>
> > > http://ben.reser.org
> > > 
> > > What difference does it make to the dead, the orphans, and the homeless,
> > > whether the mad destruction is wrought under the name of totalitarianism
> > > or the holy name of liberty and democracy? - Ghandi
> > > 
> > 
> > 
> >  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
> >      POST TO: spug-list at pm.org       PROBLEMS: owner-spug-list at pm.org
> >       Subscriptions; Email to majordomo at pm.org:  ACTION  LIST  EMAIL
> >   Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address
> >  For daily traffic, use spug-list for LIST ;  for weekly, spug-list-digest
> >      Seattle Perl Users Group (SPUG) Home Page: http://seattleperl.org
> > 
> > 
> 
> 



 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
     POST TO: spug-list at pm.org       PROBLEMS: owner-spug-list at pm.org
      Subscriptions; Email to majordomo at pm.org:  ACTION  LIST  EMAIL
  Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address
 For daily traffic, use spug-list for LIST ;  for weekly, spug-list-digest
     Seattle Perl Users Group (SPUG) Home Page: http://seattleperl.org





More information about the spug-list mailing list