Sending default code back to browser

Discussion in 'Perl Misc' started by Page, Dec 12, 2003.

  1. Page

    Page Guest

    I'm not sure how this would work, but I'm guessing it's possible...

    I have a Perl script that retrieves one of either two types of files, gifs
    and pdfs. It works well. The URL specifices which gif or pdf is to be
    returned. The script finds the file on the server, opens it, and sends it
    to the user's browser window.

    My problem is when the user specifies a file that doesn't exist. Because of
    the nuances of Internet Explorer, if the user used a URL to view a PDF, the
    next time that user uses that same url, a PDF is expected by IE to be
    returned. If I try to return HTML text saying, "Sorry, file not found", IE
    has trouble rendering it since it isn't a PDF this time. So what I'd like
    to do is return a "default" PDF or GIF in the event that the file isn't
    found. I don't want to create a default PDF or GIF file though. In other
    words, I'd like to hardcode the GIF or PDF info in the Perl script.

    Is this as easy as opening a PDF in a text editor, copying the code, and
    pasting it into a Perl Print statement (making sure to send the appropriate
    content headers of course)? When I open a GIF in a text editor, I get some
    pretty weird looking Hex code, so I didn't know if this approach would work.
    Page, Dec 12, 2003
    #1
    1. Advertising

  2. Page wrote:
    > My problem is when the user specifies a file that doesn't exist.
    > Because of the nuances of Internet Explorer, if the user used a URL
    > to view a PDF, the next time that user uses that same url, a PDF is
    > expected by IE to be returned. ...


    Do you have a Perl question?

    --
    Gunnar Hjalmarsson
    Email: http://www.gunnar.cc/cgi-bin/contact.pl
    Gunnar Hjalmarsson, Dec 12, 2003
    #2
    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. Raj
    Replies:
    8
    Views:
    79,522
    elizas
    Apr 19, 2010
  2. yasin
    Replies:
    1
    Views:
    598
    Karl Seguin [MVP]
    Apr 20, 2006
  3. Replies:
    0
    Views:
    1,354
  4. Author
    Replies:
    6
    Views:
    3,085
    George
    Jan 22, 2009
  5. David Thielen

    pop-up browser persist data back to parent page code-behind

    David Thielen, Mar 23, 2006, in forum: ASP .Net Web Controls
    Replies:
    7
    Views:
    182
    Steven Cheng[MSFT]
    Mar 29, 2006
Loading...

Share This Page