| Author |
Perl and Internet Explorer
|
|
| akaliel 2004-04-02, 1:32 pm |
| Hi everyone, I'm having a problem with cgi perl scripts. We have a
perl based Intranet that contains mostly pdf documents. When a user
wants to view a file they simply click on a link and a perl script
figures out which file they want to view and streams it to their
browser. It works just fine for PDF's. The Acrobat plugin launches
and loads the file. However, we also have Powerpoint files on the
Intranet as well. These do not behave properly. What happens is the
Open/Save dialog comes up. If you click Save then it tries to save it
as a .pl file. If you click open Windows uses whatever program is set
in File Types to open .pl files (usually Notepad).
The only solution seems to be if you click Save and then manually
change the extension from .pl to .ppt. Which isn't a problem for me,
but the less computer savvy people around here can't handle it.
There aren't any problems in Netscape. It defaults the extension to
..ppt and clicking Open instead of Save launches Powerpoint correctly.
I know that Netscape works because it reads the MIME type correctly
(application/ppt), and IE doesn't work b/c in Microsoft's infinite
wisdom, they've programmed IE to ignore MIME types.
So I've deduced these as my options. I either need a Powerpoint
plugin that goes into the "Internet Explorer/plugin" directory, much
like that of Acrobat. Figure out how to get IE to READ my MIME types.
Or use some backhanded method to default the IE extension to .ppt for
Powerpoint files.
Note that I cannot simply rename my perl script to be .ppt instead of
..pl because then it wouldn't run at all. It has to be .pl.
Much help would be very appreciated. Thanks very much,
Allan
| |
| Scott Bryce 2004-04-02, 1:32 pm |
| akaliel wrote:
> IE doesn't work b/c in Microsoft's infinite
> wisdom, they've programmed IE to ignore MIME types.
And that is the problem. It has nothing to do with Perl. There are some
headers you can send to try to clarify things for the browser, but IE
ignores those too.
| |
| Joe Smith 2004-04-02, 3:30 pm |
| akaliel wrote:
> The only solution seems to be if you click Save and then manually
> change the extension from .pl to .ppt. Which isn't a problem for me,
> but the less computer savvy people around here can't handle it.
HTML: Download <A HREF="/cgi-bin/select-file.pl/1.ppt">Project 1</A>.
CGI: Check $ENV{PATH_INFO} if no $ENV{QUERY_STRING}.
-Joe
| |
| Matt Garrish 2004-04-02, 6:31 pm |
|
"akaliel" <akaliel@streamflo.com> wrote in message
news:7123bc57.0404020925.2f5f99ab@posting.google.com...
> Hi everyone, I'm having a problem with cgi perl scripts. We have a
> perl based Intranet that contains mostly pdf documents. When a user
> wants to view a file they simply click on a link and a perl script
> figures out which file they want to view and streams it to their
> browser.
Any reason why you need to "stream" the files to the browser instead of
simply redirecting to the resource? Or is it just a case of that's the way
the script works?
Matt
| |
| akaliel 2004-04-05, 11:37 am |
| "Matt Garrish" <matthew.garrish@sympatico.ca> wrote in message news:<9Elbc.21720$j57.1219296@news20.bellglobal.com>...
> "akaliel" <akaliel@streamflo.com> wrote in message
> news:7123bc57.0404020925.2f5f99ab@posting.google.com...
>
> Any reason why you need to "stream" the files to the browser instead of
> simply redirecting to the resource? Or is it just a case of that's the way
> the script works?
>
> Matt
They have to stream because that's the way the script has to work. I
can't redirect to the resource. Not unless I can convince my boss
that it's absolutely necessary, which, if you know the guy will
realize why that isn't likely to happen. The main reason he wanted
streaming n the first place is because he was paranoid about people
knowing the the directory structure of where files are stored on the
webserver.
| |
| akaliel 2004-04-05, 7:30 pm |
| "gnari" <gnari@simnet.is> wrote in message news:<c4m4bl$lnr$1@news.simnet.is>...
> "akaliel" <akaliel@streamflo.com> wrote in message
> news:7123bc57.0404020925.2f5f99ab@posting.google.com...
>
> [snip IE problem]
>
> use the $ENV{PATH_INFO} trick if your webserver supports it,
> or just drop IE. there are plenty of alternatives
>
> gnari
Heh, stupid me. My boss was actually searching for a solution at the
same time and came across my post. Doh! Busted!
Well, he explained to me why it's necessary to have files stream. It
makes sense. You see we have security in a database that gives
certain users permission to view certain links. If a person could
just be able to type in the filename they wished to see, then that
circumvents all our security. So that's why it needs to stream.
The PATH_INFO trick might work, I'll have to try it.
I actually did get it working half way. I got it so that if you right
click and select "Save Target As" then it will default to a .ppt file.
Though if you left click on the link, nothing happens. Absolutely
nothing at all.
Almost there. I'm convinced the solution lies in the registry. I'll
let you know if I find it.
| |
| Matt Garrish 2004-04-05, 8:30 pm |
|
"akaliel" <akaliel@streamflo.com> wrote in message
news:7123bc57.0404020925.2f5f99ab@posting.google.com...
>
> There aren't any problems in Netscape. It defaults the extension to
> .ppt and clicking Open instead of Save launches Powerpoint correctly.
> I know that Netscape works because it reads the MIME type correctly
> (application/ppt), and IE doesn't work b/c in Microsoft's infinite
> wisdom, they've programmed IE to ignore MIME types.
>
I didn't look closely at your MME type the first time. The correct type for
IIS should be:
application/vnd.ms-powerpoint
Not sure if it will make any difference to IE, but might be worth a try. And
if it does work but blows up Netscape you could always detect the browser
type and send the appropriate header.
Matt
| |
| akaliel 2004-04-06, 4:34 pm |
| > Not sure if it will make any difference to IE, but might be worth a try. And
> if it does work but blows up Netscape you could always detect the browser
> type and send the appropriate header.
>
> Matt
That's the MIME type I'm using that managed to get it to partially
work. Right clicking on the link will allow me to save it as a .ppt
by default. However, left clicking on the link does nothing
whatsoever. If I right click and say "Open in New Window" then just
after the new window launches, it crashes.
| |
| Matt Garrish 2004-04-06, 6:31 pm |
|
"akaliel" <akaliel@streamflo.com> wrote in message
news:7123bc57.0404061154.595341a@posting.google.com...
And[color=darkred]
browser[color=darkred]
>
> That's the MIME type I'm using that managed to get it to partially
> work. Right clicking on the link will allow me to save it as a .ppt
> by default. However, left clicking on the link does nothing
> whatsoever. If I right click and say "Open in New Window" then just
> after the new window launches, it crashes.
I assume you've already tried the following http header to specify a default
filename?
Content-Disposition: attachment; filename=[FILENAME]
If so, then I'm out of ideas...
Matt
| |
| akaliel 2004-04-07, 12:39 pm |
| > I assume you've already tried the following http header to specify a default
> filename?
>
> Content-Disposition: attachment; filename=[FILENAME]
>
> If so, then I'm out of ideas...
>
> Matt
Umm, no I hadn't. But I tried it and lo! It worked! More
specifically, I had to enter the following perl code to handle ppt and
exe files accordingly:
my $attachment;
if ($type_name eq 'PowerPoint Presentation') {
$attachment = "$filename.ppt";
}
elsif ($type_name eq 'EXE File') {
$attachment = "$filename.exe";
}
else {
$attachment = "";
}
print $q->header({-disposition=>'inline',
-type=>$header,
-attachment=>$attachment});
while (<FILE> ) {
print $_;
}
close(FILE);
$| = 0; # turn on buffering of stdout
I'm going to clean it up a bit by actually having a mysql table handle
that bit of hardcoding I added that decides the proper extension for
the given file type. But it worked great. Thanks for all your help.
Allan
| |
| Richard Morse 2004-04-07, 3:31 pm |
| In article <1xFcc.4987$BF2.609573@news20.bellglobal.com>,
"Matt Garrish" <matthew.garrish@sympatico.ca> wrote:
> "akaliel" <akaliel@streamflo.com> wrote in message
> news:7123bc57.0404061154.595341a@posting.google.com...
> And
> browser
>
> I assume you've already tried the following http header to specify a default
> filename?
>
> Content-Disposition: attachment; filename=[FILENAME]
You might try Content-Disposition: inline; filename=... instead -- this
may make the streaming work...
Ricky
--
Pukku
| |
| Matt Garrish 2004-04-07, 9:31 pm |
|
"Richard Morse" <remorse@partners.org> wrote in message
news:remorse-D191C2.14260907042004@plato.harvard.edu...
> In article <1xFcc.4987$BF2.609573@news20.bellglobal.com>,
> "Matt Garrish" <matthew.garrish@sympatico.ca> wrote:
>
try.[color=darkred]
default[color=darkred]
>
> You might try Content-Disposition: inline; filename=... instead -- this
> may make the streaming work...
>
Good point. (From his reply, I think he figured it out on his own though.)
Matt
| |
|
| "akaliel" <akaliel@streamflo.com> wrote in message
news:7123bc57.0404020925.2f5f99ab@posting.google.com...
[snip IE problem]
use the $ENV{PATH_INFO} trick if your webserver supports it,
or just drop IE. there are plenty of alternatives
gnari
|
|
|
|