Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > Perl and Internet Explorer

Reply
Thread Tools

Perl and Internet Explorer

 
 
akaliel
Guest
Posts: n/a
 
      04-02-2004
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
 
Reply With Quote
 
 
 
 
Joe Smith
Guest
Posts: n/a
 
      04-02-2004
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
 
Reply With Quote
 
 
 
 
Matt Garrish
Guest
Posts: n/a
 
      04-02-2004

"akaliel" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) om...
> 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


 
Reply With Quote
 
gnari
Guest
Posts: n/a
 
      04-03-2004
"akaliel" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) om...

[snip IE problem]

use the $ENV{PATH_INFO} trick if your webserver supports it,
or just drop IE. there are plenty of alternatives

gnari





 
Reply With Quote
 
akaliel
Guest
Posts: n/a
 
      04-05-2004
"Matt Garrish" <(E-Mail Removed)> wrote in message news:<9Elbc.21720$(E-Mail Removed) m>...
> "akaliel" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed) om...
> > 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


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.
 
Reply With Quote
 
akaliel
Guest
Posts: n/a
 
      04-05-2004
"gnari" <(E-Mail Removed)> wrote in message news:<c4m4bl$lnr$(E-Mail Removed)>...
> "akaliel" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed) om...
>
> [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.
 
Reply With Quote
 
Matt Garrish
Guest
Posts: n/a
 
      04-05-2004

"akaliel" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) om...
>
> 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


 
Reply With Quote
 
akaliel
Guest
Posts: n/a
 
      04-06-2004
> 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.
 
Reply With Quote
 
Matt Garrish
Guest
Posts: n/a
 
      04-06-2004

"akaliel" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) m...
> > 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.


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


 
Reply With Quote
 
akaliel
Guest
Posts: n/a
 
      04-07-2004
> 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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Internet Explorer 8: C:\Program Files\Internet Explorer\iexplore.exe vs C:\Program Files (x86)\Internet Explorer\iexplore.exe Nathan Sokalski Windows 64bit 16 02-22-2010 08:31 AM
internet explorer 7 - Internet Explorer cannot display the webpag sandy j Windows 64bit 0 05-02-2009 02:12 AM
Internet Explorer + Windows Explorer + Browsing Sad Computer Support 1 09-08-2004 05:53 PM
Windows Explorer - Internet explorer JamesBenson Computer Support 19 07-31-2004 12:54 AM
can surf in Windows Explorer not Internet Explorer Billh Computer Support 0 05-02-2004 08:47 PM



Advertisments