Sending default code back to browser

P

Page

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.
 
G

Gunnar Hjalmarsson

Page said:
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?
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,540
Members
45,025
Latest member
KetoRushACVFitness

Latest Threads

Top