You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Dennis Daupert <dd...@csc.com> on 2002/11/20 00:02:19 UTC

How do I force a 'Save Window?'

I have file upload working, can upload files of ascii or binary format.
But a problem when you browse to a page that dynamically displays
hyperlinks to files. Text and html files display normally in a browser,
and Word docs popup MS Word as a helper app, and the word doc
opens fine. But MS Project files popup a browser instance and MS
Project, and you get the usual "Enable macros" and such popups as
normal, but only  a subset of the project displays in the browser window,
and none of the buttons are active in the Project application. Bummer.

How can I force a "Save File" dialog screen for selected files, so the user
will have the option to download the file, then open it in Project or
whatever?


Thanks for any help or information.

/dennis

---------------------------------------------------------------------------
Office phone: 817-762-8304

---------------------------------------------------------------------------
 "Great leaders never tell people how to do their jobs.
   Great leaders tell people what to do and establish a
         framework within which it must be done.
          Then they let people on the front lines,
       who know best, figure out how to get it done."
            ~ General H. Norman Schwarzkopf





Re: How do I force a 'Save Window?'

Posted by Issac Goldstand <ma...@beamartyr.net>.
Becuase some browsers and mail clients don't follow the RFC.  The RFC
clearly states that "When a mail reader encounters mail with an unknown
Content-type value, it should generally treat it as equivalent to
'application/octet-stream'" (SECTION 4 last paragraph - page 12)  So my
suggestion should actually translate into "application/octet-stream".
However, I've noted that where many browsers do all sorts of strange,
interesting, and usually unexepcted things when it parses
application/octet-stream, they'll usually do exactly what you want if you
confuse them with a type that they've certainly never heard of.

  Issac

----- Original Message -----
From: "Tom Hukins" <to...@eborcom.com>
To: "Issac Goldstand" <ma...@beamartyr.net>
Cc: "Dennis Daupert" <dd...@csc.com>; <mo...@perl.apache.org>
Sent: Wednesday, November 20, 2002 12:27 PM
Subject: Re: How do I force a 'Save Window?'


> On Wed, Nov 20, 2002 at 11:24:33AM +0200, Issac Goldstand wrote:
> > To force the save window is easy - make up your own content subtype
(main
> > type application)  and set it:
> >
> > Content-Type: application/x-download-this-file-you-stupid-browser
> >
> > Remember to start with an "x-" as your type is obviously not registered
with
> > the IANA.
>
> Why not use the "application/octet-stream" MIME type as recommended in
> RFC 1521?
>
> Tom
>


Re: How do I force a 'Save Window?'

Posted by Tom Hukins <to...@eborcom.com>.
On Wed, Nov 20, 2002 at 11:24:33AM +0200, Issac Goldstand wrote:
> To force the save window is easy - make up your own content subtype (main
> type application)  and set it:
> 
> Content-Type: application/x-download-this-file-you-stupid-browser
> 
> Remember to start with an "x-" as your type is obviously not registered with
> the IANA.

Why not use the "application/octet-stream" MIME type as recommended in
RFC 1521?

Tom

Re: How do I force a 'Save Window?'

Posted by Issac Goldstand <ma...@beamartyr.net>.
To force the save window is easy - make up your own content subtype (main
type application)  and set it:

Content-Type: application/x-download-this-file-you-stupid-browser

Remember to start with an "x-" as your type is obviously not registered with
the IANA.

The tricky part is setting up the default file name - if your script is
http://foo.com/cgi-bin/download.pl?filename=bar the save dialog will default
to download.pl; not to the expected "bar".

The solution is to force the file name out of the query string.  You want to
create a URI that looks like
http://foo.com/download/bar?param1=val1&param2=val2 or even better:
http://foo.com/download/val1/val2/bar

You should use mod_rewrite to take requests of this scheme and translate it
to
http://foo.com/cgi-bin/download.pl?filename=bar&param1=val1&param2=val2...
The magic is that you then tell mod_rewrite to trigger an INTERNAL redirect,
so the server works flawlessly without any funny configurations and the
browser never sees it.

If you're using a mod_perl handler, another way to do it is set up a
location /download that calls your handler and read the filename (and
possibly the parameters) directly out of the URI using the request object,
but that's a bit harder (although more elegant and probably uses less
resources then the big mighty mod_rewrite's rewrite engine).

  Issac

----- Original Message -----
From: "Dennis Daupert" <dd...@csc.com>
To: <mo...@perl.apache.org>
Sent: Wednesday, November 20, 2002 1:02 AM
Subject: How do I force a 'Save Window?'


> I have file upload working, can upload files of ascii or binary format.
> But a problem when you browse to a page that dynamically displays
> hyperlinks to files. Text and html files display normally in a browser,
> and Word docs popup MS Word as a helper app, and the word doc
> opens fine. But MS Project files popup a browser instance and MS
> Project, and you get the usual "Enable macros" and such popups as
> normal, but only  a subset of the project displays in the browser window,
> and none of the buttons are active in the Project application. Bummer.
>
> How can I force a "Save File" dialog screen for selected files, so the
user
> will have the option to download the file, then open it in Project or
> whatever?
>
>
> Thanks for any help or information.
>
> /dennis
>
> --------------------------------------------------------------------------
-
> Office phone: 817-762-8304
>
> --------------------------------------------------------------------------
-
>  "Great leaders never tell people how to do their jobs.
>    Great leaders tell people what to do and establish a
>          framework within which it must be done.
>           Then they let people on the front lines,
>        who know best, figure out how to get it done."
>             ~ General H. Norman Schwarzkopf
>
>
>
>


Re: How do I force a 'Save Window?'

Posted by Tim Tompkins <ti...@arttoday.com>.
That should be "stream" not "steam" :)


Regards,

Tim Tompkins
----------------------------------------------
Programmer
http://www.clipart.com/
http://www.rebelartist.com/
----------------------------------------------
----- Original Message -----
From: "Tim Tompkins" <ti...@arttoday.com>
To: <mo...@perl.apache.org>; "Dennis Daupert" <dd...@csc.com>
Sent: Tuesday, November 19, 2002 4:27 PM
Subject: Re: How do I force a 'Save Window?'


> You can always set the content type to "application/octet-steam" but I
> wouldn't expect IE to honor the content type.
>
>
> Regards,
>
> Tim Tompkins
> ----------------------------------------------
> Programmer
> http://www.clipart.com/
> http://www.rebelartist.com/
> ----------------------------------------------
> ----- Original Message -----
> From: "Dennis Daupert" <dd...@csc.com>
> To: <mo...@perl.apache.org>
> Sent: Tuesday, November 19, 2002 4:02 PM
> Subject: How do I force a 'Save Window?'
>
>
> > I have file upload working, can upload files of ascii or binary format.
> > But a problem when you browse to a page that dynamically displays
> > hyperlinks to files. Text and html files display normally in a browser,
> > and Word docs popup MS Word as a helper app, and the word doc
> > opens fine. But MS Project files popup a browser instance and MS
> > Project, and you get the usual "Enable macros" and such popups as
> > normal, but only  a subset of the project displays in the browser
window,
> > and none of the buttons are active in the Project application. Bummer.
> >
> > How can I force a "Save File" dialog screen for selected files, so the
> user
> > will have the option to download the file, then open it in Project or
> > whatever?
> >
> >
> > Thanks for any help or information.
> >
> > /dennis
> >
>
> --------------------------------------------------------------------------
> -
> > Office phone: 817-762-8304
> >
>
> --------------------------------------------------------------------------

> -
> >  "Great leaders never tell people how to do their jobs.
> >    Great leaders tell people what to do and establish a
> >          framework within which it must be done.
> >           Then they let people on the front lines,
> >        who know best, figure out how to get it done."
> >             ~ General H. Norman Schwarzkopf
> >
> >
> >
> >
>


Re: How do I force a 'Save Window?'

Posted by si...@siberian.org.
I guess its a your mileage may vary sort of thing. The 
marketing folks here use XP and whatever IE comes with it. 
I send 

$r->content_type( 'application/vnd.ms-excel' ) ;
         $r->header_out('Content-Disposition' => 
'attachment; filename=report.xls' ) ;
         #$r->content_type( 'application/octet-stream' ) ;
         $r->send_http_header;

and for their XP boxes it opens properly in browser ( same 
for project ). They are posting to index.html in this case 
but get the filename properly. 

On my mac os x I actually get a file named 'report.xls' in 
my save dialog.

So, as often is the case, Your Mileage May Vary :)

John-

On 20 Nov 2002 22:00:25 +0100
  Marcin Kasperski <Ma...@acn.waw.pl> wrote:
>> Bonus Points : Use
>> Content-Disposition: attachment;filename=blabla
>> 
>> and pre-set the name of the file on disk.
>
>I tried it hard (in my case I generate PDF files. No way. 
>Internet
>Explorer ignored it. Finally I decided to perform 
>redirect to URL
>ending with /blabla.pdf - then it worked more-or-less as 
>expected.
>
>-- 
>( Marcin Kasperski   | A reusable framework that is 
>developed by itself will )
>( http://www.mk.w.pl |        probably not be very 
>reusable. (Martin)        )
>(----------------------------------------------------------------------------)
>( Porady dla twórców serwisów WWW: 
>http://www.mk.w.pl/porady/porady_www      )


Re: How do I force a 'Save Window?'

Posted by Marcin Kasperski <Ma...@acn.waw.pl>.
> Bonus Points : Use
> Content-Disposition: attachment;filename=blabla
> 
> and pre-set the name of the file on disk.

I tried it hard (in my case I generate PDF files. No way. Internet
Explorer ignored it. Finally I decided to perform redirect to URL
ending with /blabla.pdf - then it worked more-or-less as expected.

-- 
( Marcin Kasperski   | A reusable framework that is developed by itself will )
( http://www.mk.w.pl |        probably not be very reusable. (Martin)        )
(----------------------------------------------------------------------------)
( Porady dla twórców serwisów WWW: http://www.mk.w.pl/porady/porady_www      )

Re: How do I force a 'Save Window?'

Posted by Kevin Berggren <ke...@systemmaker.com>.
For IE 5.5, IE doesn't respect the Content-Disposition header and will 
prompt the user to save a file as "foo.pl" (or whatever the name of your 
script happens to be)

M$ claims that this was fixed in IE 5.5 SP1.

They document this bug (as fixed) here:
http://support.microsoft.com/default.aspx?scid=kb;EN-US;267991

-kb



siberian@siberian.org wrote:

> Quick google search shows :
>
> http://www.utoronto.ca/webdocs/HTMLdocs/Book/Book-3ed/appb/mimetype.html
>
> Send the mime type as : application/vnd.ms-project
> I do this with excel using application/vnd.ms-excel and the marketing
> folks love it.
> So, you would have to provide a link to your modperl app that opens the
> file and pushes it out with this content type.
>
> Bonus Points : Use
> Content-Disposition: attachment;filename=blabla
>
> and pre-set the name of the file on disk.
>
> John-
>
> John-
>
> On Tue, 19 Nov 2002 16:27:33 -0700
>  "Tim Tompkins"  wrote:
>
> > You can always set the content type to "application/octet-steam" but I
> > wouldn't expect IE to honor the content type.
> >
> >
> > Regards,
> >
> > Tim Tompkins
> > ----------------------------------------------
> > Programmer
> > http://www.clipart.com/
> > http://www.rebelartist.com/
> > ----------------------------------------------
> > ----- Original Message -----
> > From: "Dennis Daupert"
> > To:
> > Sent: Tuesday, November 19, 2002 4:02 PM
> > Subject: How do I force a 'Save Window?'
> >
> >
> >> I have file upload working, can upload files of ascii or binary format.
> >> But a problem when you browse to a page that dynamically displays
> >> hyperlinks to files. Text and html files display normally in a browser,
> >> and Word docs popup MS Word as a helper app, and the word doc
> >> opens fine. But MS Project files popup a browser instance and MS
> >> Project, and you get the usual "Enable macros" and such popups as
> >> normal, but only  a subset of the project displays in the browser
> >> window,
> >> and none of the buttons are active in the Project application. Bummer.
> >>
> >> How can I force a "Save File" dialog screen for selected files, so the
> >
> > user
> >
> >> will have the option to download the file, then open it in Project or
> >> whatever?
> >>
> >>
> >> Thanks for any help or information.
> >>
> >> /dennis
> >>
> >> 
> -------------------------------------------------------------------------- 
>
> >>
> >
> > -
> >
> >> Office phone: 817-762-8304
> >>
> >> 
> -------------------------------------------------------------------------- 
>
> >>
> >
> > -
> >
> >>  "Great leaders never tell people how to do their jobs.
> >>    Great leaders tell people what to do and establish a
> >>          framework within which it must be done.
> >>           Then they let people on the front lines,
> >>        who know best, figure out how to get it done."
> >>             ~ General H. Norman Schwarzkopf
> >>
> >>
> >>
> >>
> >
>


-- 
----------------------------------------------------
Kevin Berggren				760-480-1828
System Maker, Inc	       3913 Sierra Linda Dr.
				 Escondido, CA 92025


Re: How do I force a 'Save Window?'

Posted by si...@siberian.org.
Quick google search shows :

http://www.utoronto.ca/webdocs/HTMLdocs/Book/Book-3ed/appb/mimetype.html

Send the mime type as : application/vnd.ms-project 

I do this with excel using application/vnd.ms-excel and 
the marketing folks love it. 

So, you would have to provide a link to your modperl app 
that opens the file and pushes it out with this content 
type.

Bonus Points : Use
Content-Disposition: attachment;filename=blabla

and pre-set the name of the file on disk.

John-

John-

On Tue, 19 Nov 2002 16:27:33 -0700
  "Tim Tompkins" <ti...@arttoday.com> wrote:
>You can always set the content type to 
>"application/octet-steam" but I
>wouldn't expect IE to honor the content type.
>
>
>Regards,
>
>Tim Tompkins
>----------------------------------------------
>Programmer
>http://www.clipart.com/
>http://www.rebelartist.com/
>----------------------------------------------
>----- Original Message -----
>From: "Dennis Daupert" <dd...@csc.com>
>To: <mo...@perl.apache.org>
>Sent: Tuesday, November 19, 2002 4:02 PM
>Subject: How do I force a 'Save Window?'
>
>
>> I have file upload working, can upload files of ascii or 
>>binary format.
>> But a problem when you browse to a page that dynamically 
>>displays
>> hyperlinks to files. Text and html files display 
>>normally in a browser,
>> and Word docs popup MS Word as a helper app, and the 
>>word doc
>> opens fine. But MS Project files popup a browser 
>>instance and MS
>> Project, and you get the usual "Enable macros" and such 
>>popups as
>> normal, but only  a subset of the project displays in 
>>the browser window,
>> and none of the buttons are active in the Project 
>>application. Bummer.
>>
>> How can I force a "Save File" dialog screen for selected 
>>files, so the
>user
>> will have the option to download the file, then open it 
>>in Project or
>> whatever?
>>
>>
>> Thanks for any help or information.
>>
>> /dennis
>>
>> --------------------------------------------------------------------------
>-
>> Office phone: 817-762-8304
>>
>> --------------------------------------------------------------------------
>-
>>  "Great leaders never tell people how to do their jobs.
>>    Great leaders tell people what to do and establish a
>>          framework within which it must be done.
>>           Then they let people on the front lines,
>>        who know best, figure out how to get it done."
>>             ~ General H. Norman Schwarzkopf
>>
>>
>>
>>
>


Re: How do I force a 'Save Window?'

Posted by Tim Tompkins <ti...@arttoday.com>.
You can always set the content type to "application/octet-steam" but I
wouldn't expect IE to honor the content type.


Regards,

Tim Tompkins
----------------------------------------------
Programmer
http://www.clipart.com/
http://www.rebelartist.com/
----------------------------------------------
----- Original Message -----
From: "Dennis Daupert" <dd...@csc.com>
To: <mo...@perl.apache.org>
Sent: Tuesday, November 19, 2002 4:02 PM
Subject: How do I force a 'Save Window?'


> I have file upload working, can upload files of ascii or binary format.
> But a problem when you browse to a page that dynamically displays
> hyperlinks to files. Text and html files display normally in a browser,
> and Word docs popup MS Word as a helper app, and the word doc
> opens fine. But MS Project files popup a browser instance and MS
> Project, and you get the usual "Enable macros" and such popups as
> normal, but only  a subset of the project displays in the browser window,
> and none of the buttons are active in the Project application. Bummer.
>
> How can I force a "Save File" dialog screen for selected files, so the
user
> will have the option to download the file, then open it in Project or
> whatever?
>
>
> Thanks for any help or information.
>
> /dennis
>
> --------------------------------------------------------------------------
-
> Office phone: 817-762-8304
>
> --------------------------------------------------------------------------
-
>  "Great leaders never tell people how to do their jobs.
>    Great leaders tell people what to do and establish a
>          framework within which it must be done.
>           Then they let people on the front lines,
>        who know best, figure out how to get it done."
>             ~ General H. Norman Schwarzkopf
>
>
>
>