Perl and Internet Explorer

Discussion in 'Perl Misc' started by akaliel, Apr 2, 2004.

  1. akaliel

    akaliel Guest

    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
     
    akaliel, Apr 2, 2004
    #1
    1. Advertising

  2. akaliel

    Joe Smith Guest

    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
     
    Joe Smith, Apr 2, 2004
    #2
    1. Advertising

  3. akaliel

    Matt Garrish Guest

    "akaliel" <> wrote in message
    news:...
    > 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
     
    Matt Garrish, Apr 2, 2004
    #3
  4. akaliel

    gnari Guest

    "akaliel" <> wrote in message
    news:...

    [snip IE problem]

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

    gnari
     
    gnari, Apr 3, 2004
    #4
  5. akaliel

    akaliel Guest

    "Matt Garrish" <> wrote in message news:<9Elbc.21720$>...
    > "akaliel" <> wrote in message
    > news:...
    > > 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.
     
    akaliel, Apr 5, 2004
    #5
  6. akaliel

    akaliel Guest

    "gnari" <> wrote in message news:<c4m4bl$lnr$>...
    > "akaliel" <> wrote in message
    > news:...
    >
    > [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.
     
    akaliel, Apr 5, 2004
    #6
  7. akaliel

    Matt Garrish Guest

    "akaliel" <> wrote in message
    news:...
    >
    > 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
     
    Matt Garrish, Apr 6, 2004
    #7
  8. akaliel

    akaliel Guest

    > 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.
     
    akaliel, Apr 6, 2004
    #8
  9. akaliel

    Matt Garrish Guest

    "akaliel" <> wrote in message
    news:...
    > > 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
     
    Matt Garrish, Apr 6, 2004
    #9
  10. akaliel

    akaliel Guest

    > 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
     
    akaliel, Apr 7, 2004
    #10
  11. In article <1xFcc.4987$>,
    "Matt Garrish" <> wrote:

    > "akaliel" <> wrote in message
    > news:...
    > > > 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]


    You might try Content-Disposition: inline; filename=... instead -- this
    may make the streaming work...

    Ricky

    --
    Pukku
     
    Richard Morse, Apr 7, 2004
    #11
  12. akaliel

    Matt Garrish Guest

    "Richard Morse" <> wrote in message
    news:...
    > In article <1xFcc.4987$>,
    > "Matt Garrish" <> wrote:
    >
    > > "akaliel" <> wrote in message
    > > news:...
    > > > > 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]

    >
    > 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
     
    Matt Garrish, Apr 8, 2004
    #12
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. cmay
    Replies:
    0
    Views:
    1,154
  2. Ed Hauptman
    Replies:
    7
    Views:
    1,049
    Ed Hauptman
    Aug 7, 2009
  3. Katharina
    Replies:
    6
    Views:
    348
    J├╝rgen Exner
    Sep 25, 2005
  4. Tutico
    Replies:
    4
    Views:
    708
  5. John Smith
    Replies:
    1
    Views:
    157
    Evertjan.
    Mar 12, 2005
Loading...

Share This Page