View Full Version : Prevent the Save As... dialog when linking to files

c q
05-22-2007, 01:50 PM

I'm trying to solve this nagging problem for a while now.. but haven't succeeded yet.

I have an e library database implemented, where teachers can upload their resources (could be ppt, pdf, doc whatever...)

they can then use each others' resources in their elearning courses by adding a link.

I noticed that everytime i try to link something in a course, clicking them throws up a "save as" dialog. Whether i link them, add them in a frame, iframe or a separate popup window altogether.

I want to force the files to open in the browser window itself. How can I make it happen?

thanks in advance.
c q.

05-22-2007, 04:28 PM
The dialog box is a function of the PC itself. With Windows, you can
tell the browser to "open as" any particular filetype without a dialog box.
You don't really have control over that with your website.

On my PC with Firefox, when I click on a PDF link, it opens it right up with
Acrobat Reader in it's own window, same with .doc type .. only because I
set-up the "open with" filetypes that define which program opens which links.

There are ways to output .doc and .pdf (and other types) directly into the
browser using some server-side scripts. Things like PDF to HTML on-the-fly.
This involves having your own server with the PHP or Perl modules installed.

This type of thing is very similar to PHP GD library which can alter .jpeg
images (resize, crop, watermark, etc) on-the-fly before serving them to
the visitor's browser ... instead, it does the same thing with various text

05-22-2007, 10:01 PM
Whether a SaveAs displays depends on two things.

1. Is the file being delivered to the browser with a disposition of inline or attachment. If attachment then the SaveAs will always display.
2. For disposition inline, it then depends on whether the browser knows how to display it. If it can display the file it will, if it can't it will offer SaveAs.

c q
05-23-2007, 08:46 AM
Well I am running it in my own WAMP server.

How do i configure the headers so that the browser loads the document inline no matter what the client browser setting? Also, if the user does not have the right application (say acrobat for pdfs...) I would like some script to prevent the save as dialog box.

any pointers, friends?

05-23-2007, 12:29 PM
If the browser doesn't have a plugin to handle a particular file type then it can't display that file in the browser regardless. You can force a file to be offered for download by setting the Content-disposition to attachment but you can't force it to load in a browser if the browser or browser owner doesn't want it to.

05-23-2007, 12:35 PM
You may be interested to know that PDF and DOC files are not suitable for online reading due to being bad for usability and accessibility.

My advice would be to always force a download for this type of content, and to provide it in HTML for online use as well.

See http://www.useit.com/alertbox/20030714.html for more info <-- this equally applies to other non standard document formats as well.

c q
05-23-2007, 01:17 PM
i don't like pdfs either, but unfortunately, I have to use this file format because my bosses seem to love it. I am already facing problems with slideshows not behaving the same in different computers due to different acrobat reader versions. But i have to work around it but i cannot abandon pdf.

What they essentially want is that the documents should only be readable on screen. No printing options, no save as options. Ofcourse, i could argue that one can still take screenshots and print, or recover the file from their temp folders... but we're talking about fairly non techie bank operations staff here. It would be enough if they are not given any save as options upfront in the website. They would not try too hard to recover them.

One answer is a rights management server... but its an expensive affair.

The other solution is to password protect the file. My elearning portal can pass variables into the files, so only legitimate open requests which are routed through the elearning server can open the file. Even if they save the file and go home, they'd need a password to open it. Now again, they would not be so desperate as to get a password crack.

But this is a slightly wrong forum to ask this in... still.... does anyone know what variable name is this password field known as in a pdf? :-/

05-23-2007, 05:23 PM
I would say that you would be looking into something other than an
internet browser. Like a dedicated program in C++ or VBasic that
is similar to a kiosk. This could then turn-off any screen saving, printing,
keyboard functions, etc ... making the mouse the only input device.

Some sort of software like that could access the files from the internet,
yet have total control over the viewer, unlike a browser.

You should look into some Kiosk type software.